AJAX and XMLHttpRequest object
Using XMLHttpRequest object we can:
- Update a web page without reloading it
- Request data from a web server after the page has been loaded
- Receive data from a web server after the page has been loaded
- Send data to a web server in the background
Create an XMLHttpRequest Object
All major web browsers (Firefox, Chrome, IE7+, Safari, Opera) have a built-in XMLHttpRequest object.
Syntax for creating an XMLHttpRequest object:
variable = new XMLHttpRequest();
Old versions of Internet Explorer (IE5 and IE6) use an ActiveX object instead of the XMLHttpRequest object.
So, for handling IE5 and IE6, we have to check if the browser supports the XMLHttpRequest object, or else create an ActiveX object:
variable = new ActiveXObject("Microsoft.XMLHTTP");