Skip to content

moxie.xhr.XMLHttpRequest

Davit Barbakadze edited this page Aug 5, 2017 · 2 revisions

Important! This page is auto-generated from the comments in the source files. All changes will be overwritten! If you are looking to contribute, modify the comment in the corresponding source file instead.

Module: moxie.xhr.XMLHttpRequest

Table of Contents

Constructor

Implementation of XMLHttpRequest

Properties

The amount of milliseconds a request can take before being terminated. Initially zero. Zero means there is no timeout.

Current state, can take following values: UNSENT (numeric value 0) The object has been constructed.

OPENED (numeric value 1) The open() method has been successfully invoked. During this state request headers can be set using setRequestHeader() and the request can be made using the send() method.

HEADERS_RECEIVED (numeric value 2) All redirects (if any) have been followed and all HTTP headers of the final response have been received. Several response members of the object are now available.

LOADING (numeric value 3) The response entity body is being received.

DONE (numeric value 4)

True when user 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.

Returns the HTTP status code.

Returns the HTTP status text.

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

Returns the document response entity body.

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

Returns the text response entity body.

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

Returns the response entity body (http://www.w3.org/TR/XMLHttpRequest/#response-entity-body). Can become: ArrayBuffer, Blob, Document, JSON, Text

Unique id of the component

Target for Upload events

Methods

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

Throws a "SyntaxError" exception if one of the following is true:

method is not a valid HTTP method. url cannot be resolved. url contains the "user:password" format in the userinfo production. Throws a "SecurityError" exception if method is a case-insensitive match for CONNECT, TRACE or TRACK.

Throws an "InvalidAccessError" exception if one of the following is true:

Either user or password is passed as argument and the origin of url does not match the XMLHttpRequest origin. There is an associated XMLHttpRequest document and either the timeout attribute is not zero, the withCredentials attribute is true, or the responseType attribute is not the empty string.

Arguments

  • method String
    HTTP method to use on request
  • url String
    URL to request
  • [async=true] Boolean
    If false request will be done in synchronous manner. Asynchronous by default.
  • [user] String
    Username to use in HTTP authentication process on server-side
  • [password] String
    Password to use in HTTP authentication process on server-side

Appends an header to the list of author request headers, or if header is already in the list of author request headers, combines its value with value.

Throws an "InvalidStateError" exception if the state is not OPENED or if the send() flag is set. Throws a "SyntaxError" exception if header is not a valid HTTP header field name or if value is not a valid HTTP header field value.

Arguments

  • header String

  • value String|Number

Test if the specified header is already set on this request. Returns a header value or boolean false if it's not yet set.

Arguments

  • header String
    Name of the header to test

Returns all headers from the response, with the exception of those whose field name is Set-Cookie or Set-Cookie2.

Returns the header field value from the response of which the field name matches header, unless the field name is Set-Cookie or Set-Cookie2.

Arguments

  • header String

Sets the Content-Type header for the response to mime. Throws an "InvalidStateError" exception if the state is LOADING or DONE. Throws a "SyntaxError" exception if mime is not a valid media type.

Arguments

Initiates the request. The optional argument provides the request entity body. The argument is ignored if request method is GET or HEAD.

Throws an "InvalidStateError" exception if the state is not OPENED or if the send() flag is set.

Arguments

  • [data] Blob|Document|String|FormData
    Request entity body
  • [options] Object
    Set of requirements and pre-requisities for runtime initialization

Cancels any network activity.