Skip to main content

au-widget-ajax/IAuWidgetAjaxConfig

Classes​

ResponseErrorContext​

Provides HTTP response properties.

Constructors​

Constructor​
new ResponseErrorContext(): ResponseErrorContext;
Returns​

ResponseErrorContext

Properties​

body​
body: any;

The response body.

headers​
headers: Headers;

A dictionary of HTTP headers sent along with the response.

statusCode​
statusCode: number;

An HTTP response status code.

Interfaces​

IAuWidgetAjaxConfig​

Provides properties that are used to send requests to the server and receive responses.

You can use these properties in params of the AuWidgetAjax class.

The following example illustrates how you can populate a gallery with images obtained through an HTTP request.

{
"widgets": [
{
"name": "gallery-images",
"type": "ajax",
"params": {
"lock": "gallery",
"url": "https://example.com/api/images?subfolder=cats",
"method": "GET",
"responseType": "json"
}
}
]
}

Properties​

enabled​
enabled: boolean;

If false, the request will not be executed. The default value is true.

headers​
headers: object;

A dictionary of HTTP headers sent along with the request (an object with the keys used as a header name and a value used as a header value).

Index Signature​
[key: string]: string
lock​
lock: string | string[];

The widget names that should be locked while waiting for the response. The editor will show a preloader on this widget.

method​
method: string;

An HTTP method like POST, GET, etc. The default value is POST.

onError​
onError: Function | Function[];

A function ("{{#function <expression>}}") or an array of functions that should work when the request fails.

onSuccess​
onSuccess: Function | Function[];

A function ("{{#function <expression>}}") or an array of functions that work after the successful request.

request​
request: any;

The request body. Typically, you put a JSON here that consists of references to other widgets.

requests​
requests: any[];
responseType​
responseType: ResponseType;

Defines how to interpret the response received from the server.

url​
url: string;

A URL that is used to accept requests.


IRequestModel​

Provides HTTP request properties.

Properties​

enabled​
enabled: boolean;

If false, the request will not be executed.

headers​
headers: object;

A dictionary of HTTP headers sent along with the request.

Index Signature​
[key: string]: string
method​
method: string;

An HTTP method.

request​
request: any;

The request body.

responseType​
responseType: ResponseType;

Defines how to interpret the response received from the server.

url​
url: string;

A URL that is used to accept requests.

Type Aliases​

ErrorsCallback​

type ErrorsCallback = (errorData) => void;

Defines a function that should work when a request fails.

Parameters​

ParameterType
errorDataResponseErrorContext

Returns​

void


ResponseType​

type ResponseType = "text" | "blob" | "json" | "blob_url" | "status_code";

A response type specifying how to interpret the response received from the server.

Text​

  • a raw text string. The Ajax widget does not try to interpret it.

Json​

  • a JSON object. When you refer the response in your config, you can access its properties.

Blob​

  • binary data. It makes sense to use it along with some widgets that can work with binary data directly. @blob_url - binary data, but it is converted to the Blob URL, which can be used with HTML markup. @status_code - an HTTP code.
Was this page helpful?