An Object of XMLHttpRequest is used to send HTTP or HTTPS requests to a web server and load the server response data back, without reloading the page.
How to create an XMLHttpRequest Object?
All modern browsers (IE7+, Firefox, Chrome, Safari, and Opera) have a built-in XMLHttpRequest object.
Syntax:- variable=new XMLHttpRequest();
Old versions of Internet Explorer (IE5 and IE6) uses an ActiveX Object:
Syntax:- variable=new ActiveXObject(“Microsoft.XMLHTTP”);
Properties of XMLHttpRequest object
0: request not initialized
1: server connection established
2: request received
3: processing request
4: request finished and response is ready
404: Page not found
Note:- When readyState is 4 and status is 200, the response is ready.
Methods of XMLHttpRequest object
To send a Request To a Server, with the help of the open() and send() methods of the XMLHttpRequest object.
method: the type of request: GET or POST
url: the location of the file on the server
async: true (asynchronous) or false (synchronous)
string: Only used for POST requests.
Example:- xmlhttp.open(“GET”,”getting_ajax_info.php”,true);
xmlhttp.send();