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 (0.10), 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_once "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_export("multiply"); // list of functions to export sajax_handle_client_request(); // serve client instances - Setup your HTML (including the JavaScript the library generates)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Test</title> <!-- Requred for older browsers --> <script type="text/javascript" src="json_stringify.js"></script> <!-- The main client side script --> <script type="text/javascript" src="sajax.js"></script>
<script type="text/javascript"><!-- // The generated JavaScript for your functions
<?php sajax_show_javascript(); ?>
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);
}
// Function to handle the returned value from PHP
function set_math_result(result) {
document.getElementById("z").value = 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?
Care has been taken to make sure that Sajax works in as many browsers as posible. If you experience problems, please contact us and let us know.
IE6 and up is fully functional and supported.
Firefox (all versions) is fully functional and supported.
Safari 1.2 and up is fully functional and supported.
Mozilla 0.9.9 and up is fully functional and supported.
Opera 8.2-10b3 is fully functional and supported.
Opera Mobile 8.0-9.7 is fully functional and supported.
Opera Mini 4.0-4.2 is fully functional and supported.
Mobile IE 7.11 is fully functional and supported.
Fennec M10 is fully functional and supported.
Netscape 6.1 and up is fully functional and supported.
Konqure 4.2 has been tested and works.
iCab 4.0 and up is fully functional and supported.
iCab 3.0-3.0.5 is fully functional, but might fail is json_parse_state.js is loaded.
IE5-5.5 will forece GET mode and be limited to sending 512 bytes per request.
Mozilla 0.9.4-0.9.8 will forece GET mode and be limited to sending 512 bytes per request.
Opera 8.0 will forece GET mode and be limited to sending 512 bytes per request.
Opera 8.1 will fail on POST.
IE5 for mac is unsupported and will fail.
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
- Does not fall back to <IFRAME>s
Known issues
- iCab 3.0.5 will fail badly when using json_parse_state.js and receving large stings.
- IE 5.01 will fail nicly when using json_parse.js.
- Prototype 1.5.1 and later, 1.6.0.3 is the latest at this point, breaks firefox's JSON.stringify(), a workaround for this is to use the methode provided by Prototype instead, to do this, include the folowing code just after you load prototype.js
The upside to this is that you don't need to include any of the JSON.stringify or JSON.parse implementations for older browsers.<script type="text/javascript"><!-- var JSON = JSON || {}; JSON.stringify = function(value) { return value.toJSON(); }; JSON.parse = JSON.parse || function(jsonsring) { return jsonsring.evalJSON(true); }; //--> </script>
Why did it move to sajax.info
The original development team at www.modernmethod.com had stoped developing on the libery, sajax.info was started to give Sajax a much needed tune up and make the changes avalibe to every one.