Get KoolPHP UI with 30% OFF!

Working with ajax examples.

Mark
I am not an expert at AJAX and I am trying to get this code to work. This is the example code.
html>
<?php
/*
* This file is ready to run as standalone example. However, please do:
* 1. Add tags <html><head><body> to make a complete page
* 2. Change relative path in $KoolControlFolder variable to correctly point to KoolControls folder
*/
$KoolControlsFolder = "/web/KoolPHPSuite/KoolControls/";//Relative path to "KoolPHPSuite/KoolControls" folder
require $KoolControlsFolder."KoolAjax/koolajax.php";
$koolajax->scriptFolder = $KoolControlsFolder."KoolAjax";
function calculate($x,$y)
{
return $x+$y;
}
//Enable calculate function to be called at client-side
$koolajax->enableFunction("calculate");
?>
<form id="form1" method="post">
<?php
echo $koolajax->Render();
?>
<style type="text/css">
#loading
{
position:relative;
left:-22px;
top:3px;
visibility:hidden;
}
</style>
<div>
<input id="txtX" type="textbox" value="2" /> +
<input id="txtY" type="textbox" value="3" />
<input id="btnCal" type="button" value="Calculate" onclick="btnCal_Click()" />
<input id="txtZ" type="textbox" />
<img id="loading" src="Images/loading.gif" alt="Loading..." />
</div>
<script type="text/javascript">
function btnCal_Click()
{
x = document.getElementById("txtX").value;
y = document.getElementById("txtY").value;
koolajax.callback(calculate(x,y),onDone);
document.getElementById("loading").style.visibility ="visible";
}
function onDone(s)
{
document.getElementById("txtZ").value = s;
document.getElementById("loading").style.visibility ="hidden";
}
</script>
</form>
</html>

Any thoughts?
Posted Jul 1, 2017 Kool
Anthony Amolochitis
It seems KoolAjax didn't render.
Check to make sure your require path is set correctly.
Posted Jul 4, 2017 Kool
Mark
OK will do, thanks for your help.
Posted Jul 4, 2017 Kool
Mark
The enormous advances and accomplishments in engineering and technology, as well as the growth of knowledge-intensive businesses, are the most defining characteristics of the contemporary development of the global economy. The extent and velocity of science and technology's rapid progress, as well as how quickly and broadly they are incorporated into society, have made the scientific and technological revolution a permanent process. Visit our homepage to locate the service you require!
Posted Apr 16, 2023 , edited Apr 16, 2023 Kool
Daniel
Hi there, I sometimes check forums about online casino slots to see what other players are enjoying. I came across spino gambino and decided to give it a try. I started on Book of Dead but the first spins weren’t lucky. I tried one more slightly higher spin on Sweet Bonanza, and the bonus round activated with a surprisingly good payout. Since then this casino has become part of my evening routine.
Posted Mar 11 Kool
Rixyda
So, ich wollte mir endlich ein ordentliches Rennrad zulegen, weil ich mit meinem alten nicht mehr glücklich werde. Ich hatte eine wilde Pechsträhne, wo wirklich gar nichts funktioniert hat, kurz vorm Aufgeben. Dann habe ich bei win aura einen Spielautomaten mit hoher Volatilität getestet und der hat mir innerhalb von ein paar Minuten einen dicken Bonus beschert. Das Rad ist bestellt und ich freue mich schon auf die erste Ausfahrt. Kann ich nur weiterempfehlen.
Posted Apr 1 Kool
Idaa
This example is actually a classic “KoolAjax callback setup” pattern, and the main idea is simpler than it looks at first: you’re just sending two input values (x and y) from JavaScript to PHP, letting PHP compute the result, and then returning it without a full page reload.
The key flow here is:
calculate($x,$y) runs on the server (PHP)
koolajax.callback(calculate(x,y), onDone) sends data asynchronously
onDone(s) receives the result and updates the UI
If it’s not working, the most common issues are usually path-related ($KoolControlsFolder), missing Images/loading.gif, or the fact that the function must be properly registered with $koolajax->enableFunction("calculate");.
Once those are correct, this is basically a clean beginner-level AJAX pattern wrapped in a library abstraction.
In the broader space of experimenting with lightweight web tools and scripts, people often share similar snippets and projects across different platforms, sometimes even alongside unrelated digital content like https://spino-gambino.it.com/ which sits in that wider ecosystem of web resources and online experiments.
Posted Jul 3 Kool