Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface HttpRequest

Hierarchy

Index

Properties

Optional async

async: boolean

By default, all requests are sent asynchronously (i.e. this is set to true by default).

Optional cache

cache: boolean

If set to false, it will force requested pages not to be cached by the browser. Note: Setting cache to false will only work correctly with HEAD and GET requests. It works by appending "_={timestamp}" to the GET parameters. The parameter is not needed for other types of requests, except in IE8 when a POST is made to a URL that has already been requested by a GET.

Optional complete

complete: (res: HttpResponse) => void

A function to be called when this request finishes (after success and error callbacks are executed).

Type declaration

Optional converts

converts: { arraybuffer?: <T>(data: ArrayBuffer) => T; blob?: <T>(data: Blob) => T; html?: <T>(data: HTMLDocument) => T; json?: <T>(data: JsonObject) => T; text?: <T>(data: string) => T; xml?: <T>(data: XMLDocument) => T }

An object containing type converters. Each parser's value is a function that returns the filtered response data of the type, will be replaced a default inner-parser.

Type declaration

  • Optional arraybuffer?: <T>(data: ArrayBuffer) => T
      • <T>(data: ArrayBuffer): T
      • Type parameters

        • T

        Parameters

        • data: ArrayBuffer

        Returns T

  • Optional blob?: <T>(data: Blob) => T
      • <T>(data: Blob): T
      • Type parameters

        • T

        Parameters

        • data: Blob

        Returns T

  • Optional html?: <T>(data: HTMLDocument) => T
      • <T>(data: HTMLDocument): T
      • Type parameters

        • T

        Parameters

        • data: HTMLDocument

        Returns T

  • Optional json?: <T>(data: JsonObject) => T
  • Optional text?: <T>(data: string) => T
      • <T>(data: string): T
      • Type parameters

        • T

        Parameters

        • data: string

        Returns T

  • Optional xml?: <T>(data: XMLDocument) => T
      • <T>(data: XMLDocument): T
      • Type parameters

        • T

        Parameters

        • data: XMLDocument

        Returns T

Optional crossCookie

crossCookie: 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.

Optional data

data: string | JsonObject | FormData | ArrayBuffer | Blob

Data to be sent to the server.

Optional error

error: (res: HttpResponse) => void

A function to be called if this request fails.

Type declaration

Optional headers

headers: JsonObject<string | null | undefined>

An object of additional header key/value pairs to send along with requests using the XMLHttpRequest transport. The header X-Requested-With: XMLHttpRequest is always added, but its default XMLHttpRequest value can be changed here.

Optional ifModified

ifModified: boolean

Allow the request to be successful only if the response has changed since the last request. This is done by checking the Last-Modified header. Default value is false, ignoring the header. This technique also checks the 'etag' specified by the server to catch unmodified data.

Optional method

method: "HEAD" | "GET" | "POST" | "OPTIONS" | "PUT" | "DELETE"

The HTTP method to use for the request.

Optional overrideResponseMime

overrideResponseMime: string

The XMLHttpRequest method overrideMimeType() specifies a MIME type other than the one provided by the server to be used instead when interpreting the data being transferred in a request. This may be used, for example, to force a stream to be treated and parsed as "text/xml", even if the server does not report it as such.

Optional password

password: string

A password to be used with XMLHttpRequest in response to an HTTP access authentication request.

Optional progress

progress: (e: ProgressEvent, xhr: XMLHttpRequest) => void

A function to be called if this request progress.

Type declaration

    • (e: ProgressEvent, xhr: XMLHttpRequest): void
    • Parameters

      • e: ProgressEvent
      • xhr: XMLHttpRequest

      Returns void

Optional requestMime

requestMime: string | false

When sending data to the server, use this content type. Default is "application/x-www-form-urlencoded; charset=UTF-8", which is fine for most cases. If you explicitly pass in a content-type to $.ajax(), then it is always sent to the server (even if no data is sent). You can pass false to tell Http to not set any content type header. Note: The W3C XMLHttpRequest specification dictates that the charset is always UTF-8; specifying another charset will not force the browser to change the encoding. Note: For cross-domain requests, setting the content type to anything other than application/x-www-form-urlencoded, multipart/form-data, or text/plain will trigger the browser to send a preflight OPTIONS request to the server.

Optional responseType

responseType: HttpResponseType

"xml": Returns a XML document that can be processed.
"html": Returns HTML as plain text; included script tags are evaluated when inserted in the DOM.
"json": Evaluates the response as JSON and returns a JavaScript object.
"text": A plain text string.

Optional success

success: (res: HttpResponse) => void

A function to be called if this request succeeds.

Type declaration

Optional thread

thread: boolean | ThreadPreload

Send in a new webwork thread.

Optional timeout

timeout: number

Set a timeout (in milliseconds) for the request. A value of 0 means there will be no timeout.

url

url: string

An URL string for ajax request.

Optional username

username: string

A username to be used with XMLHttpRequest in response to an HTTP access authentication request.

Methods

Optional responseFilter

  • A function to be used to pre-handle the raw response data beforing parse the response.

    Parameters

    Returns any