XMLHttpRequest : Object

Object that transfers data between a web client and a remote web server.

Browser/User Agent Support

IEMozillaNetscapeOperaSafariNetscapte
7.0+1.0+7.0+nonono

Constructors

ConstructorIEMozillaNetscapeOperaSafariNetscapte
Creates a new instance of an XMLHttpRequest object.
7.0+1.0+7.0+nonono
 

Properties

PropertyIEMozillaNetscapeOperaSafariNetscapte
Event handler that fires when readystate changes value. Default is null.
7.0+1.0+7.0+nonono
 
Returns the current state of an object. Valid values are 0 = uninitialized, 1 = open, 2 = sent, 3 = receiving, 4 = loaded.
7.0+1.0+7.0+nonono
 
Response formatted as a string.
7.0+1.0+7.0+nonono
 
Response formatted as an XML document.
7.0+1.0+7.0+nonono
 
Status of the Response. (e.g. 200 = "OK", 404 = "Not Found", etc.)
7.0+1.0+7.0+nonono
 
Response text corresonding to status (e.g. "OK", "Not Found", etc.)
7.0+1.0+7.0+nonono
 

Methods

MethodIEMozillaNetscapeOperaSafariNetscapte
Cancels the current request.
7.0+1.0+7.0+nonono
 
Returns all HTTP headers as a single string.
7.0+1.0+7.0+nonono
 
Returns the value of the specified HTTP header.
7.0+1.0+7.0+nonono
 
Initializes the request with the specified parameters.
7.0+1.0+7.0+nonono
 
Sends the request.
7.0+1.0+7.0+nonono
 
Sets a header and a value for the request.
7.0+1.0+7.0+nonono
 

Remarks

Although currently recognized by most browsers, the XMLHttpRequest object will be part of the HTML DOM Level 3 specification.

Availability

HTML DOM Level 3 | W3C

Constructor Detail

XMLHttpRequest XMLHttpRequest()

Creates a new instance of an XMLHttpRequest object.

Visibility
internal

Property Detail

Function onreadystatechange

Event handler that fires when readystate changes value. Default is null.

Availability

HTML DOM Level 3 | W3C

Number readyState - read only

Returns the current state of an object. Valid values are 0 = uninitialized, 1 = open, 2 = sent, 3 = receiving, 4 = loaded.

Availability

HTML DOM Level 3 | W3C

String responseText - read only

Response formatted as a string.

Availability

HTML DOM Level 3 | W3C

Document responseXML - read only

Response formatted as an XML document.

Number status - read only

Status of the Response. (e.g. 200 = "OK", 404 = "Not Found", etc.)

Availability

HTML DOM Level 3 | W3C

String statusText - read only

Response text corresonding to status (e.g. "OK", "Not Found", etc.)

Availability

HTML DOM Level 3 | W3C

Method Detail

abort() : void

Cancels the current request.

Remarks
Although currently recognized by most browsers, the XMLHttpRequest object will be part of the HTML DOM Level 3 specification.
Availability

HTML DOM Level 3 | W3C

getAllResponseHeaders() : String

Returns all HTTP headers as a single string.

Remarks
Although currently recognized by most browsers, the XMLHttpRequest object will be part of the HTML DOM Level 3 specification.
Availability

HTML DOM Level 3 | W3C

getResponseHeader(String header) : String

Returns the value of the specified HTTP header.

StringheaderName of the HTTP header.

Remarks
Although currently recognized by most browsers, the XMLHttpRequest object will be part of the HTML DOM Level 3 specification.
Availability

HTML DOM Level 3 | W3C

open(String method, String uri, [Boolean async,] [String user,] [String password]) : void

Initializes the request with the specified parameters.

StringmethodName of the HTTP method. Specify a value of GET, POST, HEAD, or PUT.
StringuriComplete URI or relative URI that can be resolved to a complete URI.
BooleanasyncIf true, specifies that the request should be handled asyncrhonously. (optional)
StringuserUsername to send in the request. (optional)
StringpasswordPassword to send in the request. (optional)

Remarks
Although currently recognized by most browsers, the XMLHttpRequest object will be part of the HTML DOM Level 3 specification.
Availability

HTML DOM Level 3 | W3C

send(String, Document data) : void

Sends the request.

String, DocumentdataData (content) to send for the request. Can be a String or an XML Document.

Remarks
Although currently recognized by most browsers, the XMLHttpRequest object will be part of the HTML DOM Level 3 specification.
Throws
Throws an INVALID_STATE_ERR error if the send method is called when readyState has an inappropriate value.
Availability

HTML DOM Level 3 | W3C

setRequestHeader(String, Document header, String, Document value) : void

Sets a header and a value for the request.

String, DocumentheaderName of the header.
String, DocumentvalueValue of the header.

Remarks
Although currently recognized by most browsers, the XMLHttpRequest object will be part of the HTML DOM Level 3 specification.
Throws
Throws an UNKNOWN_ERR error.
Availability

HTML DOM Level 3 | W3C