require_once('../includes/prepend.php'); include('saja.php'); $saja = new Saja; //used to set the path to the 4 saja files - this can also be set permanently in saja.php (var $saja_path = '{/path/to/saja/}') $saja->set_path('/demo/'); //define whether or not to use *true* utf8 support (recommended keep false unless you fully understand the shortcomings of PHP and UTF8!!) //the default PHP string functions cannot handle UTF-8 properly, so you must be careful when manipulating the input $saja->set_true_utf8(false); //the default process file is set to saja.functions.php //use this method if you want to use some other process file by default $saja->set_process_file('saja.functions.php'); //used to encrypt any HTTP data that SAJA transmits (OPTIONAL) //if you do not call this method, your function calls will still be secure, but the data sent will be unencrypted //this method should be used sparingly, and is usually not necessary unless you have good reason to encrypt the data. $saja->secure_http(); ?> $title = 'Secure AJAX for PHP'; include('../includes/header.php'); ?> =$saja->saja_js()?> =$saja->saja_status('background-color:red; position:absolute; top:0px; left:0px')?>
Note: Sourceforge servers are fairly slow due to their high demand. You can expect SAJA to perform much faster on a more responsive host. On the up-side, this allows you to fully experience the sajaStatus "Working..." indicator, as well as observe what happens when you multithread saja requests by clicking the buttons really fast.
Saja can handle the UTF-8 character set, use the area below to test. The response should echo unchanged on the right hand side. Please beware that the PHP string functions are not capable of handling UTF-8, so you may experience strange problems if you do not take special care. Notice the incorrect string length as calculated by PHP.
| PHP String Length: |
In the limited UTF-8 mode (default) some characters will be interpreted as question marks, but you won't have trouble with string manipulation in PHP. Most of the time you'll be fine in this mode unless you want to use characters outside of most european languages. Notice that some characters are converted to ?, but the string length as calculated by PHP is correct.
| PHP String Length: |
One of the major shortcomings of ajax applications is that they tend to break the traditional browser navigation - if a user clicks the "back" button they find themselves suddenly on an unexpected page. SAJA provides a simple solution to this problem by storing the previous AJAX request data in a javascript history chain. Try clicking the 3 buttons below in order, then use the "back" and "forward" buttons on your browser to "navigate" your previous ajax requests! Please note that there are logical and practical limitations to this feature as explained in greater detail here: ajax + browser history explained.
This demo uses a simple php function to either add two numbers or concatinate two strings,
depending on the input. This function is being called from a separate library, "moreFunctions.php", instead of the
standard "saja.functions.php" file.
+ =
Use SAJA to make a request to retrieve the title of the URL you type in. **The sourceforge server can only request documents on the sourceforge domain, sorry!
URL:Observe a delay created by the PHP sleep function, as well as callback response order.
Send JavaScript Objects directly into your php functions.
Try clicking around on these form elements to calculate the answer.
lastnum");?> return false;">10 =Add One to the answer?
Text contains: characters.
Background Color: # Text Color: #
//history initial condition echo $saja->saja_history("ecco('hello!')->historyTest"); ?>