XMLHttpRequest

With AJAX, your JavaScript communicates directly with the server, through the JavaScript XMLHttpRequest object. It provides an easy way to retrieve data at a URL. Despite its name, XMLHttpRequest can be used to retrieve any type of data, not just XML, and it supports connections other than HTTP (including file and ftp).
To create an instance of XMLHttpRequest, simply do this:
1
var req = new XMLHttpRequest();
All new browsers use the built-in JavaScript XMLHttpRequest object to create an XMLHttpRequest object.
The JavaScript code for creating an XMLHttpRequest object:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
if (window.XMLHttpRequest)
{
 
   // code for IE7+, Firefox, Chrome, Opera, Safari
 
   return new XMLHttpRequest();
 
}
 
if (window.ActiveXObject)
 
{
 
   // code for IE6, IE5
 
   return new ActiveXObject("Microsoft.XMLHTTP");
 
}