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

(1) onreadystatechange
Stores a function (or the name of a function) to be called automatically each time the readyState property changes
(2) readyState
represents the state of the request. It ranges from 0 to 4.
0: request not initialized
1: server connection established
2: request received
3: processing request
4: request finished and response is ready
(3) status
200: “OK”
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.

Specifies the type of request, the URL, and if the request should be handled asynchronously or not.
method: the type of request: GET or POST
url: the location of the file on the server
async: true (asynchronous) or false (synchronous)
Sends the request off to the server.
string: Only used for POST requests.

Example:- xmlhttp.open(“GET”,”getting_ajax_info.php”,true);