Java Reference
In-Depth Information
The XMLHttpRequest Object
The XMLHttpRequest object was finally standardized by the WHATWG and W3C as part of
the HTML5 specification, despite it originally being implemented by Microsoft many years
earlier and already available in most browsers.
XMLHttpRequest2 was a draft API specification intended to extend the original XMLHt-
tpRequest object. It added some useful features such as CORS and form data (covered later
in this chapter). Since the end of 2011, the specifications were merged and are now simply
known as XMLHttpRequest.
XMLHttpRequest is a constructor function that returns an object with methods for send-
ing and receiving data. Older versions of Internet Explorer (before version 7) implemented
this using an ActiveX object, but all modern browsers now support it natively.
To create a new XMLHttpRequest object, use the following code:
var xhr = new XMLHttpRequest();
The XMLHttpRequest object has a property called readystate . This is an integer value
that corresponds to the status of the request:
the open() method has yet to be called
after the open() method, but before the send() method has been called
the send() method has been called and the HTTP headers and status code have been
Search WWH ::

Custom Search