03 - Creating and sending XMLHttpRequest

Creating and sending XMLHttpRequest

For exchanging information between a webpage and a server, you use a XMLHttpRequest object. And as mentioned before, this will allow us to update different parts of a web page without having to reload the entire web page.

xmlHTTPRequest = new XMLHttpRequest();

Once you have your XMLHttpRequest object you can now exchange information with the server, to do this you will use two methods from the object:

- open(TypeOfRequest,ServerURL,CommunicationType)

o TypeOfRequest: set it to GET or POST

o serverURL: the location of the file retrieved

o CommunicationType: TRUE for Asynchronous or FALSE for Synchronous


- send(data)

o data: a String object with additional data needed for POST requests.


Like us on Facebook