Class: XMLHttpRequest

whatwg-xhr.XMLHttpRequest()

new XMLHttpRequest()

Interface that represents the objects used to interact with a server.
Source:

Extends

Members

(constant) DONE :number

State of XMLHttpRequest object, the operation is complete.
Type:
  • number
Default Value:
  • 4
Source:

(constant) HEADERS_RECEIVED :number

State of XMLHttpRequest object, send() has been called, headers and status are available.
Type:
  • number
Default Value:
  • 2
Source:

(constant) LOADING :number

State of XMLHttpRequest object, downloading, responseText holds partial data.
Type:
  • number
Default Value:
  • 3
Source:

(constant) OPENED :number

State of XMLHttpRequest object, open() has been called.
Type:
  • number
Default Value:
  • 1
Source:

(constant) UNSENT :number

State of XMLHttpRequest object, client has been created, open() not called yet.
Type:
  • number
Default Value:
  • 0
Source:

onabort :function

Get/Set the event handler fired whenever the 'abort' event is emitted.
Type:
  • function
Inherited From:
Source:

onerror :function

Get/Set the event handler fired whenever the 'error' event is emitted.
Type:
  • function
Inherited From:
Source:

onload :function

Get/Set the event handler fired whenever the 'load' event is emitted.
Type:
  • function
Inherited From:
Source:

onloadend :function

Get/Set the event handler fired whenever the 'loadend' event is emitted.
Type:
  • function
Inherited From:
Source:

onloadstart :function

Get/Set the event handler fired whenever the 'loadstart' event is emitted.
Type:
  • function
Inherited From:
Source:

onprogress :function

Get/Set the event handler fired whenever the 'progress' event is emitted.
Type:
  • function
Inherited From:
Source:

onreadystatechange :function

Get/Set the event handler fired whenever there's change in readyState.
Type:
  • function
Source:

ontimeout :function

Get/Set the event handler fired whenever the 'timeout' event is emitted.
Type:
  • function
Inherited From:
Source:

(readonly) readyState :number

Get the state an XMLHttpRequest client is in.
Type:
  • number
Source:

(readonly) response :ArrayBuffer|Blob|Document|object|string

Get the response's body content received from a server following a request being sent.
Type:
  • ArrayBuffer | Blob | Document | object | string
Source:

(readonly) responseText :string

Get the text received from a server following a request being sent.
Type:
  • string
Source:

responseType :string

Get/Set an enumerated string value specifying the type of data contained in the response.
Type:
  • string
Source:

(readonly) responseURL :string

Get the serialized URL of the response or the empty string if the URL is null.
Type:
  • string
Source:

(readonly) responseXML :Document|null

Get a Document containing the HTML or XML retrieved by the request, or null.
Type:
  • Document | null
Source:

(readonly) status :number

Get the numerical HTTP status code of the server response.
Type:
  • number
Source:

(readonly) statusText :string

Get the HTTP status message of the server response.
Type:
  • string
Source:

timeout :number

Get/Set an unsigned long representing the number of milliseconds a request can take before automatically being terminated.
Type:
  • number
Source:

(readonly) upload :object

Get an XMLHttpRequestUpload object that can be observed to monitor an upload's progress.
Type:
  • object
Source:

withCredentials :boolean

Get/Set a boolean value that indicates whether or not cross-site Access-Control requests should be made using credentials.
Type:
  • boolean
Source:

Methods

abort()

XMLHttpRequest method that aborts the request if it has already been sent.
Source:

getAllResponseHeaders() → {string|null}

XMLHttpRequest method that returns all the response headers, separated by CRLF, as a string, or null if no response.
Source:
Returns:
A string representing all of the response's headers, or null if no response has been received.
Type
string | null

getResponseHeader(name) → {string|null}

XMLHttpRequest method that returns the string containing the text of a particular header's value.
Parameters:
Name Type Description
name string The name of the header whose text value is required.
Source:
Returns:
The header text value or null.
Type
string | null

open(method, url, is_async, username, password)

XMLHttpRequest method that initializes a newly-created request, or re-initializes an existing one.
Parameters:
Name Type Description
method string The HTTP request method to use, such as "GET", "POST", "PUT", "DELETE", etc. Ignored for non-HTTP(S) URLs.
url string A string or any other object with a stringifier that provides the URL of the resource to request.
is_async boolean (Optional) Boolean parameter, defaulting to true, indicating whether or not to perform the operation asynchronously.
username string (Optional) user name to use for authentication purposes; by default, this is the null value.
password string (Optional) password to use for authentication purposes; by default, this is the null value.
Source:
Requires:

overrideMimeType(mime)

XMLHttpRequest method that specifies a MIME type other than the one provided by the server.
Parameters:
Name Type Description
mime string MIME type to use instead of the one specified by the server.
Source:
Requires:

send(body)

XMLHttpRequest method that sends the request to the server.
Parameters:
Name Type Description
body Document | Blob | ArrayBuffer | TypedArray | DataView | FormData | URLSearchParams | string | null The request body.
Source:
Requires:

setRequestHeader(name, value)

XMLHttpRequest method that sets the value of an HTTP request header.
Parameters:
Name Type Description
name string The name of the header whose value is to be set.
value string The value to set as the body of the header.
Source:
Requires:

A Node.js implementation of the WHATWG XMLHttpRequest Living Standard for non-browser environments.