Represents an XML request via HTTP.
Members Table
The following table lists the members exposed by the
XMLHttpRequest
object.
Show:
|
Property | Description |
---|
onreadystatechange |
Sets or retrieves the event handler for asynchronous requests. | readyState |
Retrieves the current state of the request operation. | responseBody |
Retrieves the response body as an array of unsigned bytes. | responseText |
Retrieves the response body as a string. | responseXML |
Retrieves the response body as an XML Document Object Model (DOM) object. | status |
Retrieves the HTTP status code of the request. | statusText |
Retrieves the friendly HTTP status of the request. | timeout |
Gets or sets the time-out value.
|
Event | Description |
---|
ontimeout |
Raised when there is an error that prevents the completion of the request.
|
Method | Description |
---|
abort |
Cancels the current HTTP request. | getAllResponseHeaders |
Returns the complete list of response headers. | getResponseHeader |
Returns the specified response header. | open |
Assigns method, destination URL, and other optional attributes of a pending request. | send |
Sends an HTTP request to the server and receives a response. | setRequestHeader |
Adds custom HTTP headers to the request. |
|
Remarks
The XMLHttpRequest property is available on the window object in Internet Explorer 7.
var oReq = new XMLHttpRequest;
With the XMLHttpRequest object, Internet Explorer clients can retrieve and submit XML data directly to a Web server without reloading the page. To convert XML data into renderable HTML content, use the client-side XML DOM or Extensible Stylesheet Language Transformations (XSLT) to compose HTML elements for presentation.
The native scripting object also supports the use of expandos (custom properties), and properly recognizes the 'this' notation of Javascript.
For clients prior to Internet Explorer 7, use the following syntax to create the object:
var oReq = new ActiveXObject("MSXML2.XMLHTTP.3.0");
Example
The following script demonstrates how to create and use the XMLHttpRequest object:
if (window.XMLHttpRequest)
{
var oReq = new XMLHttpRequest();
oReq.open("GET", "http://localhost/test.xml");
oReq.send();
alert(oReq.statusText);
}
Standards Information
This object is defined in
The XMLHttpRequest Object (W3C Working Draft) .