XMLHttpRequest is the basis of Ajax.
XMLHTTPRequest object
All modern browsers support XMLHttpRequest objects (ie5 and IE6 use activexobject ).
XMLHttpRequest is used to exchange data with the server in the background. This means that you can update a part of a webpage without reloading the entire webpage.
Create an XMLHTTPRequest object
All modern browsers (IE7 +, Firefox, chrome, Safari, and opera) have built-in XMLHttpRequest objects.
Syntax for creating an XMLHTTPRequest object:
Variable = new XMLHttpRequest ();
Earlier versions of Internet Explorer (ie5 and IE6) Use ActiveX objects:
Variable = new activexobject ("Microsoft. XMLHTTP ");
To handle all modern browsers, including ie5 and IE6, check whether the browser supports XMLHttpRequest objects. If yes, create an XMLHTTPRequest object. If not, activexobject is created:
VaR XMLHTTP; If (window. XMLHttpRequest) {// code for IE7 +, Firefox, chrome, opera, Safari XMLHTTP = new XMLHttpRequest ();} else {// code for IE6, ie5 XMLHTTP = new activexobject ("Microsoft. XMLHTTP ");}
Ajax-create an XMLHTTPRequest object