AJAX Request

After checking the browser support or successfully creating the XMLHttpRequest object, we can exchange the information between server and webpage by making the request using XMLHttpRequest object.

XMLHttpRequest object have the following methods to send a request to server –

Method Description
open(method,url,async) We can now open our request to the server by calling the open method that belongs to the AJAX object that we created in previous chapter.This method takes three parameters. 

method: The method parameter can have a value of “GET” or “POST”.

url: Location of the script on the server

async: TRUE or FALSE(Asynchronous means that the processing will continue on without waiting for the server side retrieval to complete whereas a synchronous call would stop all other processing and wait for the response from the server)

send(string) Sends the request to the server.string: Only used for POST requests
setRequestHeader(header,value) Adds a header/value pair to the HTTP header to be sent. 

header:Header name

value: Header value