Skip to content

AjaxOptions

Defined in: utilities/ajax/ajax.ts:13

Settings for Ajax. Only url is required.

optional cors?: boolean

Defined in: utilities/ajax/ajax.ts:49

Makes a cross-domain request with credentials: it sets xhr.withCredentials, which sends cookies. The server must then answer with Access-Control-Allow-Credentials: true and a specific origin, not *. A request to a server that allows any origin needs no option at all.

false


optional data?: string | object | null

Defined in: utilities/ajax/ajax.ts:60

Data to send: an object of names and values, which is URL-encoded (see urlParams), or a query string that is already encoded ('a=1&b=2', without the ?).

It is sent as the body for POST, PUT and DELETE, and added to the URL as query parameters for GET and JSONP.

null


optional error?: AjaxCallback

Defined in: utilities/ajax/ajax.ts:72

Called when the request fails (any other status). Not used for JSONP.


optional headers?: Record<string, string>

Defined in: utilities/ajax/ajax.ts:30

Headers to add to the request, with xhr.setRequestHeader(name, value). They are added to the default ones, and a header with the same name (the case does not matter) replaces the default.

{ 'Content-type': 'application/x-www-form-urlencoded' }


optional jsonpCallback?: string

Defined in: utilities/ajax/ajax.ts:66

JSONP only: the name of the global function the response calls. It is added to the URL as callback=<name>.


optional method?: AjaxMethod | "get" | "post" | "put" | "delete" | "jsonp"

Defined in: utilities/ajax/ajax.ts:22

The type of request. Case does not matter. An unknown method falls back to GET.

'GET'


optional responseType?: XMLHttpRequestResponseType

Defined in: utilities/ajax/ajax.ts:39

Format of xhr.response. See XMLHttpRequest.responseType. An empty value falls back to 'text'.

'text'


optional success?: AjaxCallback

Defined in: utilities/ajax/ajax.ts:69

Called when the request succeeds (status 200 to 299). Not used for JSONP.


url: string

Defined in: utilities/ajax/ajax.ts:15

Request URL.