Skip to main content

au-widget-ajax/au-widget-ajax

Classes​

AuWidgetAjax​

A non-visual widget that is used to send requests to the server and receive responses, which can be used in other widgets.

For details, see the Ajax widget topic.

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

{
"widgets": [
{
"name": "bg-request",
"type": "ajax",
"params": {
"lock": "gallery",
"url": "{{vars.apiUrl + '/api/images?subfolder=backgrounds'}}",
"method": "GET",
"responseType": "json"
}
},
{
"name": "gallery",
"title": "Gallery",
"type": "gallery",
"params": {
"prompt": "Set a background",
"showTitle": false,
"forceSelection": true,
"items": "{{ $['bg-request'].response.items }}"
}
}
]
}

Implements​

Constructors​

Constructor​
new AuWidgetAjax(): AuWidgetAjax;
Returns​

AuWidgetAjax

Inherited from​
AuBaseInvisibleWidget.constructor

Properties​

enabled​
enabled: boolean = true;

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

error​
error: any = null;
headers​
headers: any = {};

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

method​
method: string = "POST";

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

params​
params: IAuWidgetAjaxConfig;

Parameters of the Ajax widget.

Overrides​
AuBaseInvisibleWidget.params
request​
request: any;

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

requestPromise​
requestPromise: Promise<any>;

Promise, for awaiting in #function for getting response.

"{{ #function $['image-request'].compile() }}",
"{{ #asyncFunction await $['image-request'].requestPromise }}"
requests​
requests: any[];
response​
response: any;

A server response, interpreted based on the responseType param. If autoCompile is true, it is automatically updated every time the widget gets a server response.

responseHeaders​
responseHeaders: Headers = null;
responses​
responses: any = [];
responseType​
responseType: ResponseType = "json";

Defines how to interpret the response received from the server.

statusCode​
statusCode: number = null;
url​
url: string;

A URL that is used to accept requests.

Accessors​

template​
Get Signature​
get static template(): any;
Returns​

any

Inherited from​
AuBaseInvisibleWidget.template

Methods​

checkInitDependenciesWidgets()​
checkInitDependenciesWidgets(): string[];

Returns an array of widget names, due to which the current widget cannot receive parameters.

Returns​

string[]

Inherited from​
AuBaseInvisibleWidget.checkInitDependenciesWidgets
exportWidgetData()​
exportWidgetData(force): Promise<AjaxWidgetData>;
Parameters​
ParameterType
forceboolean
Returns​

Promise<AjaxWidgetData>

Implementation of​

IRestorableWidget.exportWidgetData

resetPreloaderState()​
resetPreloaderState(): void;
Returns​

void

Inherited from​
AuBaseInvisibleWidget.resetPreloaderState
restoreWidgetFromData()​
restoreWidgetFromData(widgetData, force): Promise<void>;
Parameters​
ParameterType
widgetDataAjaxWidgetData
forceboolean
Returns​

Promise<void>

Implementation of​

IRestorableWidget.restoreWidgetFromData

showPreloader()​
showPreloader(isShow): void;

Shows a preloader.

Parameters​
ParameterTypeDescription
isShowbooleanIf true, enables the preloader.
Returns​

void

Overrides​
AuBaseInvisibleWidget.showPreloader
showToast()​
showToast(data?, duration?): void;

Shows a toast.

return editor.loadUserInfo(data)
.catch(err => {
this.widget.showToast("Error: Invalid data");
console.log(err);
});
Parameters​
ParameterTypeDescription
data?stringA string message to display in the toast.
duration?numberDefines how long to show the toast for.
Returns​

void

Inherited from​
AuBaseInvisibleWidget.showToast

References​

widget​

Renames and re-exports AuWidgetAjax

Was this page helpful?