Submit Your Article
Home Articles News Tutorials Videos Add An Article
Topics: Design Photoshop Programming PHP CSS Java Database Web Development Javascript Ajax
– Close + Open

Find Out More About DevWebPro!

Sign up for the newsletter


» Terms & Conditions

Welcome to the New DevWebPro!

DevWebPro Includes:
  Hundreds Of Tutorials   Developer News
  Unique Gadget Videos   Tons of Topics to Discuss
  Expert Advice   We Will Publish Your Articles

SAJAX :Sample Ajax Toolkit

Monday, December 4th, 2006
Text: Decrease Font Size Increase Font Size | Print Print Article | Share: Delicious Digg StumbleUpon Post to Twitter Post to Facebook

What is Sajax?

Sajax is another Ajax framework which makes it easy to call ASP, Cold Fusion, Io, Lua, Perl, PHP, Python or Ruby functions from your webpages via JavaScript without performing a browser refresh.

How does SAJAX work?

SAJAX creates a JavaScript stub function that calls functions you export from your script. It handles all the connection details and calls a callback function of your design when the data is available. Here’s an example of how easy it is to use:

  1. Include the library:
    require("Sajax.php");
  2. Initialize it and tell it what functions you wish to export:
  3. Setup your HTML (including the JavaScript the library generates)


<html>
<head>
<title>Test</title>
<script>
<?
sajax_show_javascript();
?>
function set_math_result(result) {
document.getElementById("z").value = result;
}
function do_the_math() {
var x, y;
x = document.getElementById("x").value;
y = document.getElementById("y").value;
// our php function multiply() has been
// linked to a javascript function named
// x_multiply(). call it.
x_multiply(x, y, set_math_result);
}
</script>
</head>
<body>
<input type="text" name="x" id="x" value="2" size="3">
*
<input type="text" name="y" id="y" value="3" size="3">
=
<input type="text" name="z" id="z" value="" size="3">
<input type="button" name="check" value="Calculate"
onclick="do_the_math(); return false;">
</body>
</html>

Topics: , ,

Leave a Comment

DevWebPro is an iEntry Network ® publication - © 1998-2010 All Rights Reserved