Cross Browser AjaxCross Browser Ajax (CBA) is a tiny, fast, and truly cross browser library that makes adding AJAX features to your pages very easy. |
||
Version: 1.10 License: MIT (Free for all use) Library Size: 4.9Kb (Compressed) 12.8Kb (Non-compressed) |
Using the CrossBrowserAjax to create dynamic content is very simple. There are two steps.
1. Include a library file in your <head></head> section like this:
<script src="cba.js"></script>
2. Make the Ajax request and update content by calling cbaUpdateElement(elementID,url), for example:
<span id="myElement"></span><a href="javascript://" onClick="
cbaUpdateElement('myElement','userinfo.php?data=mydata');
">Update myElement</a>
It will load data returned from "userinfo.php?data=mydata" to "myElement".
That's it!
The server response in this example should look like this:
_cba.ready (
0, // request id
'Data...' // data
);
A request handler can be written in any server language (PHP, JSP, ASP etc..). Every CrossBrowserAjax response must be wrapped in _cba.ready
_cba.ready (
// your response data here
);
The server request handler for our example, written in php ( userinfo.php ):
<?php
$answer = 'Data...';
?>
_cba.ready (
<?php
echo $_GET['_cba_request_id'];
?>
, "<?php
echo addslashes($answer);
?>"
);