I just completed a tutorial at http://www.tizag.com/ajaxTutorial/ in order to get a quick look at ajax…
The tutorial goes fairly fast and gives you the basic understanding of how ajax works. Overall ajax in itself is fairly simple. I would recommend going to the 3w site for the specification.
In general there are only a few key steps to use basic ajax:
- Create the Object for the browser to use
Most browsers:
ajaxRequest = new XMLHttpRequest();IE browsers:
ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");OR
ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");- Create a listener function for the state change
ajaxRequest.onreadystatechange = function(){ . . . }
- Open and Send the request to your server side code
ajaxRequest.open("GET", "serverTime.php", true);
ajaxRequest.send(null);
- When the state is set to completed, do something
if(ajaxRequest.readyState == 4){
document.myForm.time.value = ajaxRequest.responseText;
}
There are many good sites to continue the ajax journey. Here are a couple of my favorites.
There is a series of articles on Mastering Ajax located here: