XMLHttpRequest — An HTTP request and response
Create an XMLHttpRequest object with the
XMLHttpRequest() constructor (see the
sidebar in Using XMLHttpRequest for information on how to create
an XMLHttpRequest object in IE6) and then use it like this:
open()to specify the URL and method (usually “GET” or “POST”) for the request.
onreadystatechangeproperty to the function that will be notified of the progress of the request.
setRequestHeader(), if needed, to specify additional request parameters.
send()to send the request to the web server. If it is a POST request, you can also pass a request body to this method. Your
onreadystatechangeevent handler function will be invoked as the request proceeds. When
readyStateis 4, the response is complete.
When readyState is 4, check the
statuscode to ensure that the request was successful. If so, use
getResponseHeaders()to retrieve values from the response header, and use the
responseXMLproperties to obtain the response body.
XMLHttpRequest defines a relatively high-level interface to the HTTP protocol. It takes care of details such as handling redirects, managing cookies, and negotiating cross-origin connections ...