XMLHttpRequest-Ajax

To do this, you must understand the three ways of creating an XMLHttpRequest object
• IE 5: request = new ActiveXObject("Microsoft.XMLHTTP")
• IE 6+: request = new ActiveXObject("Msxml2.XMLHTTP")
• All others: request = new XMLHttpRequest()
This is the case because Microsoft chose to implement a change with the release of
Internet Explorer.



The readyState property
Now we get to the nitty-gritty of an Ajax call, which all hangs on the readyState property.
The “asynchronous” aspect of Ajax allows the browser to keep accepting user
input and changing the screen, while our program sets the onreadystatechange property
to call a function of our choice each time readyState changes. In this case, a nameless
(or anonymous) inline function has been used, as opposed to a separate, named function.
This type of function is known as a callback function, as it is called back each time
readyState changes

request.onreadystatechange = function()
{
if (this.readyState == 4)
{
// do something
}
}