Back to Devexpress

AjaxRemoteService Class

dashboard-js-devexpress-dot-dashboard-5b308900.md

latest5.7 KB
Original Source

AjaxRemoteService Class

The Ajax-based remote service used to communicate with the server side.

Declaration

ts
export class AjaxRemoteService implements IRemoteService<JQueryXHR>

Remarks

The Ajax remote service is a IRemoteService<TResponse> implementation that exchanges information between client and server sides. You can get different information from a server (data sources, export information, a dashboard model), obtain a dashboard request time, pass custom HTTP headers, and more.

Refer to the AjaxRemoteServiceOptions class for Ajax remote service options.

You can use Web Forms, MVC, and ASP.NET Core dashboard applications as a client for a server part. See the following topic to learn more: DashboardBackendOptions.

Implements

IRemoteService

constructor

Initializes a new instance of the AjaxRemoteService class.

Declaration

ts
constructor(
    options?: DevExpress.Dashboard.AjaxRemoteServiceOptions
)

Parameters

NameTypeDescription
optionsAjaxRemoteServiceOptions

Ajax Remote service options.

|

Properties

beforeSend Property

Specifies a pre-request callback function that can be used to modify the JQueryXHR object before it is sent.

Declaration

ts
beforeSend: (jqXHR: JQueryXHR, settings: JQueryAjaxSettings) => any

Property Value

TypeDescription
(jqXHR: JQueryXHR, settings: JQueryAjaxSettings) => any

A function that can be used to modify the JQueryXHR object before it is sent.

|

complete Property

Specifies a function to be called when the request finishes (after success and error callbacks are executed).

Declaration

ts
complete?: (jqXHR: JQueryXHR, textStatus: string) => any

Property Value

TypeDescription
(jqXHR: JQueryXHR, textStatus: string) => any

A function to be called when the request finishes.

|

headers Property

Specifies an object of additional header key/value pairs to send along with requests using the XMLHttpRequest transport.

Declaration

ts
headers: {
    [key: string]: any;
}

Property Value

TypeDescription
[key: string]: any

A collections of header key/value pairs.

|

Remarks

Note

The client-side dashboard control uses form.submit to export the entire dashboard or a dashboard item. This approach doesn’t allow the application to send HTTP headers from client to server side. In this case, the dashboard control adds the <input type="hidden"> element to the form for each HTTP header from the headers collection. The hidden input element has the same ID as the HTTP header’s name. The header value is sent to the server side as the value of the corresponding field. You can use the HttpRequest.Form collection to access the hidden fields’ values on the server side.

Methods

getFromServer(url) Method

Requests data from the server with the GET method.

Declaration

ts
getFromServer(
    url: string,
    data?: Object,
    queryOptions?: JQueryAjaxSettings
): JQueryXHR

Parameters

NameTypeDescription
urlstring

A string containing the URL to which the request is sent.

| | data | Object |

Data to be sent to the server.

| | queryOptions | JQueryAjaxSettings |

The JQueryAjaxSettings options that configure the Ajax request.

|

Returns

TypeDescription
JQueryXHR

The JQueryXHR object that is a superset of the XMLHTTPRequest object.

|

performPostback(url, args) Method

Performs an export request to the server using the POST method.

Declaration

ts
performPostback(
    url: string,
    args: Object
): JQueryPromise<any>

Parameters

NameTypeDescription
urlstring

A string containing the URL to which the request is sent.

| | args | Object |

An object that contains request options.

|

Returns

TypeDescription
JQueryPromise<any>

A JQuery Promise object that is resolved after the action is completed.

|

postToServer(url) Method

Posts data to the server using the POST method.

Declaration

ts
postToServer(
    url: string,
    data?: Object
): JQueryXHR

Parameters

NameTypeDescription
urlstring

A string containing the URL to which the request is sent.

| | data | Object |

Data to be sent to the server.

|

Returns

TypeDescription
JQueryXHR

The JQueryXHR object that is a superset of the XMLHTTPRequest object.

|