Interface

XMLHttpRequest

XMLHttpRequest

Use XMLHttpRequest (XHR) objects to interact with servers. You can retrieve data from a URL without having to do a full page refresh. This enables a Web page to update just part of a page without disrupting what the user is doing.

View Source js/lib.dom.d.ts, line 7052

Members

void

# abort

Cancels any network activity.

View Source js/lib.dom.d.ts, line 7111

void

# open

Sets the request method, request URL, and synchronous flag.

Throws a "SyntaxError" DOMException if either method is not a valid HTTP method or url cannot be parsed.

Throws a "SecurityError" DOMException if method is a case-insensitive match for CONNECT, TRACE, or TRACK.

Throws an "InvalidAccessError" DOMException if async is false, current global object is a Window object, and the timeout attribute is not zero or the responseType attribute is not the empty string.

View Source js/lib.dom.d.ts, line 7116

void

# overrideMimeType

Acts as if the Content-Type header value for response is mime. (It does not actually change the header though.)

Throws an "InvalidStateError" DOMException if state is loading or done.

View Source js/lib.dom.d.ts, line 7127

number

# readyState

Returns client's state.

View Source js/lib.dom.d.ts, line 7055

any

# response

Returns the response's body.

View Source js/lib.dom.d.ts, line 7060

string

# responseText

Returns the text response.

Throws an "InvalidStateError" DOMException if responseType is not the empty string or "text".

View Source js/lib.dom.d.ts, line 7065

XMLHttpRequestResponseType

# responseType

Returns the response type.

Can be set to change the response type. Values are: the empty string (default), "arraybuffer", "blob", "document", "json", and "text".

When set: setting to "document" is ignored if current global object is not a Window object.

When set: throws an "InvalidStateError" DOMException if state is loading or done.

When set: throws an "InvalidAccessError" DOMException if the synchronous flag is set and current global object is a Window object.

View Source js/lib.dom.d.ts, line 7072

Document | null

# responseXML

Returns the document response.

Throws an "InvalidStateError" DOMException if responseType is not the empty string or "document".

View Source js/lib.dom.d.ts, line 7085

void

# send

Initiates the request. The body argument provides the request body, if any, and is ignored if the request method is GET or HEAD.

Throws an "InvalidStateError" DOMException if either state is not opened or the send() flag is set.

View Source js/lib.dom.d.ts, line 7134

void

# setRequestHeader

Combines a header in author request headers.

Throws an "InvalidStateError" DOMException if either state is not opened or the send() flag is set.

Throws a "SyntaxError" DOMException if name is not a header name or if value is not a header value.

View Source js/lib.dom.d.ts, line 7141

number

# timeout

Can be set to a time in milliseconds. When set to a non-zero value will cause fetching to terminate after the given time has passed. When the time has passed, the request has not yet completed, and the synchronous flag is unset, a timeout event will then be dispatched, or a "TimeoutError" DOMException will be thrown otherwise (for the send() method).

When set: throws an "InvalidAccessError" DOMException if the synchronous flag is set and current global object is a Window object.

View Source js/lib.dom.d.ts, line 7092

XMLHttpRequestUpload

# upload

Returns the associated XMLHttpRequestUpload object. It can be used to gather transmission information when data is transferred to a server.

View Source js/lib.dom.d.ts, line 7099

boolean

# withCredentials

True when credentials are to be included in a cross-origin request. False when they are to be excluded in a cross-origin request and when cookies are to be ignored in its response. Initially false.

When set: throws an "InvalidStateError" DOMException if state is not unsent or opened, or if the send() flag is set.

View Source js/lib.dom.d.ts, line 7104