Asynchronous Javascript with XML (AJAX)

HTTP follows Request-Response model. AJAX is the way to develop interactive applications over HTTP using the Request-Response Model. In traditional web applications, when you click on a link entire HTML page is loaded. AJAX provides a way to send a request to the server and obtain the response and display the results without having to reload the entire HTML document.

The way it usually works is, from the javascript an HTTP request is generated. When the response is received the browser does not load the page, but calls a pre-registered handler function. It is the responsibility of the handler function to process the response and update the document with necessary changes. The response can be text or xml. If the response is XML, the root of the DOM tree will be available as responseXML property of the http object. Correspondingly, the property responseText avails the response in text format.

Note that the syntax for generating http object is browser dependent. Thus, the code below will work only with Internet Explorer.

You may share this article on Facebook.