Chartbreaker
    Preparing search index...

    Interface XMLHttpRequest_2

    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.

    interface XMLHttpRequest_2 {
        DONE: number;
        HEADERS_RECEIVED: number;
        LOADING: number;
        onabort: null | ((this: XMLHttpRequest_2, ev: ProgressEvent_2) => any);
        onerror: null | ((this: XMLHttpRequest_2, ev: ProgressEvent_2) => any);
        onload: null | ((this: XMLHttpRequest_2, ev: ProgressEvent_2) => any);
        onloadend: null | ((this: XMLHttpRequest_2, ev: ProgressEvent_2) => any);
        onloadstart: null | ((this: XMLHttpRequest_2, ev: ProgressEvent_2) => any);
        onprogress: null | ((this: XMLHttpRequest_2, ev: ProgressEvent_2) => any);
        onreadystatechange: null | ((this: XMLHttpRequest_2, ev: Event_3) => any);
        ontimeout: null | ((this: XMLHttpRequest_2, ev: ProgressEvent_2) => any);
        OPENED: number;
        readyState: number;
        response: any;
        responseText: string;
        responseType: XMLHttpRequestResponseType_2;
        responseURL: string;
        status: number;
        statusText: string;
        timeout: number;
        UNSENT: number;
        withCredentials: boolean;
        abort(): void;
        addEventListener<K extends keyof XMLHttpRequestEventMap_2>(
            type: K,
            listener: (this: XMLHttpRequest_2, ev: XMLHttpRequestEventMap_2[K]) => any,
            options?: boolean | AddEventListenerOptions_3,
        ): void;
        addEventListener(
            type: string,
            listener: EventListenerOrEventListenerObject_3,
            options?: boolean | AddEventListenerOptions_3,
        ): void;
        dispatchEvent(event: Event_3): boolean;
        getAllResponseHeaders(): string;
        getResponseHeader(name: string): null | string;
        open(method: string, url: string): void;
        open(
            method: string,
            url: string,
            async: boolean,
            username?: null | string,
            password?: null | string,
        ): void;
        overrideMimeType(mime: string): void;
        removeEventListener<K extends keyof XMLHttpRequestEventMap_2>(
            type: K,
            listener: (this: XMLHttpRequest_2, ev: XMLHttpRequestEventMap_2[K]) => any,
            options?: boolean | EventListenerOptions_3,
        ): void;
        removeEventListener(
            type: string,
            listener: EventListenerOrEventListenerObject_3,
            options?: boolean | EventListenerOptions_3,
        ): void;
        send(body?: any): void;
        setRequestHeader(name: string, value: string): void;
    }

    Hierarchy (View Summary)

    Index

    Properties

    DONE: number
    HEADERS_RECEIVED: number
    LOADING: number
    onabort: null | ((this: XMLHttpRequest_2, ev: ProgressEvent_2) => any)
    onerror: null | ((this: XMLHttpRequest_2, ev: ProgressEvent_2) => any)
    onload: null | ((this: XMLHttpRequest_2, ev: ProgressEvent_2) => any)
    onloadend: null | ((this: XMLHttpRequest_2, ev: ProgressEvent_2) => any)
    onloadstart: null | ((this: XMLHttpRequest_2, ev: ProgressEvent_2) => any)
    onprogress: null | ((this: XMLHttpRequest_2, ev: ProgressEvent_2) => any)
    onreadystatechange: null | ((this: XMLHttpRequest_2, ev: Event_3) => any)
    ontimeout: null | ((this: XMLHttpRequest_2, ev: ProgressEvent_2) => any)
    OPENED: number
    readyState: number

    Returns client's state.

    response: any

    Returns the response's body.

    responseText: string

    Returns the text response.

    Throws an "InvalidStateError" DOMException if responseType is not the empty string or "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".

    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.

    responseURL: string
    status: number

    Returns the document response.

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

    statusText: string
    timeout: number

    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.

    UNSENT: number
    withCredentials: boolean

    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.

    Methods

    • Cancels any network activity.

      Returns void

    • Appends an event listener for events whose type attribute value is type. The callback argument sets the callback that will be invoked when the event is dispatched.

      The options argument sets listener-specific options. For compatibility this can be a boolean, in which case the method behaves exactly as if the value was specified as options's capture.

      When set to true, options's capture prevents callback from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE. When false (or not present), callback will not be invoked when event's eventPhase attribute value is CAPTURING_PHASE. Either way, callback will be invoked if event's eventPhase attribute value is AT_TARGET.

      When set to true, options's passive indicates that the callback will not cancel the event by invoking preventDefault(). This is used to enable performance optimizations described in § 2.8 Observing event listeners.

      When set to true, options's once indicates that the callback will only be invoked once after which the event listener will be removed.

      The event listener is appended to target's event listener list and is not appended if it has the same type, callback, and capture.

      Type Parameters

      Parameters

      Returns void

    • Appends an event listener for events whose type attribute value is type. The callback argument sets the callback that will be invoked when the event is dispatched.

      The options argument sets listener-specific options. For compatibility this can be a boolean, in which case the method behaves exactly as if the value was specified as options's capture.

      When set to true, options's capture prevents callback from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE. When false (or not present), callback will not be invoked when event's eventPhase attribute value is CAPTURING_PHASE. Either way, callback will be invoked if event's eventPhase attribute value is AT_TARGET.

      When set to true, options's passive indicates that the callback will not cancel the event by invoking preventDefault(). This is used to enable performance optimizations described in § 2.8 Observing event listeners.

      When set to true, options's once indicates that the callback will only be invoked once after which the event listener will be removed.

      The event listener is appended to target's event listener list and is not appended if it has the same type, callback, and capture.

      Parameters

      Returns void

    • Dispatches a synthetic event event to target and returns true if either event's cancelable attribute value is false or its preventDefault() method was not invoked, and false otherwise.

      Parameters

      Returns boolean

    • Returns string

    • Parameters

      • name: string

      Returns null | string

    • 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.

      Parameters

      • method: string
      • url: string

      Returns void

    • Parameters

      • method: string
      • url: string
      • async: boolean
      • Optionalusername: null | string
      • Optionalpassword: null | string

      Returns void

    • 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.

      Parameters

      • mime: string

      Returns void

    • 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.

      Parameters

      • Optionalbody: any

      Returns void

    • 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.

      Parameters

      • name: string
      • value: string

      Returns void