Frequently Asked Questions
What is Sajax?
Sajax is a tool to make programming websites using the Ajax framework — also known as XMLHTTPRequest or remote scripting — as easy as possible. Sajax 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. The toolkit does 99% of the work for you so you have no excuse to not use it.
Why is (S)Ajax a big deal?
Ajax scripting marks a dramatic shift from form-oriented web development to a more interactive, GUI-style system. Our library makes it so simple to do this that your friends will make fun of you if you don't.
Show me some examples!
Multiplier:
play with it or
see the source
Oldschool "graffiti wall":
play with it or
see the source
What languages does it support
Right now only ASP, Cold Fusion, Io, Lua, PHP, Perl, Python and Ruby. If you can contribute a backend for other systems, such as Java, please contact us for our submission guidelines.
How does it work?
Our toolkit 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:
- Include the library:
require("Sajax.php"); - Initialize it and tell it what functions you wish to export:
// the function we will be exporting to JavaScript: function multiply($x, $y) { return $x * $y; } sajax_init(); sajax_export("multiply"); // list of functions to export sajax_handle_client_request(); // serve client instances - 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>
Will it work in all browsers?
So far Sajax has worked well for us in IE6 and Mozilla/Firefox. It should be compatible with Safari. We've had mixed reports about Opera. If you experience problems, please contact us and let us know.
How much does it cost?
Nothing. It is open source and licensed under the BSD license. This means you can do basically whatever you want with it, even charge people for it.
However, if you use Sajax in your projects and find it helpful we would greatly appreciate it if you would make a donation to us. We recommend the value of one hour of your time — after all, think of the time we have saved you.
Thank you in advance for your patronage. We hope to develop many more useful web development libraries in the coming years.
Features
- Very easy to use
- Unobstrusive
- Not overly abstract
Drawbacks and Limitations
- At one point, multiple concurrent requests performed strangely. This may be fixed.
- Does not fall back to <IFRAME>s.
- Lack of type checking and support for rich return types (you can implement your own with string parsing of course).
Downloadables
The most recent version 0.12, including code and examples:
Version 0.12, code only: Sajax.php.txt