AjaxRemoteService Class
The Ajax-based remote service used to communicate with the server side.
Declaration
export class AjaxRemoteService implements IRemoteService
Remarks
The Ajax remote service is a default IRemoteService 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 so much more.
Refer to the following topics for information on how to set the server’s URL and pass a custom Authorization header from the client:
- Angular - Properties of the Object Type
- React - Change Control Properties
- Vue - Properties of the Object Type
- JavaScript Applications - Client-Side API Overview
You can also view the following example on GitHub:
Refer to the AjaxRemoteServiceOptions class for the 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
constructor
Initializes a new instance of the AjaxRemoteService
class.
Declaration
constructor(
options?: AjaxRemoteServiceOptions
)
Parameters
Name | Type | Description |
---|---|---|
options | AjaxRemoteServiceOptions | 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
beforeSend: (jqXHR: JQueryXHR, settings: JQueryAjaxSettings) => any
Property Value
Type |
---|
(jqXHR: JQueryXHR, settings: JQueryAjaxSettings) => any |
Remarks
The following code shows how to modify the JQueryXHR object before it is sent to a server:
dashboardControl.remoteService.beforeSend = function (jqXHR, settings) {
jqXHR.setRequestHeader('test', parameters);
}
complete Property
Specifies a function to be called when the request finishes (after success and error callbacks are executed).
Declaration
complete?: (jqXHR: JQueryXHR, textStatus: string) => any
Property Value
Type |
---|
(jqXHR: JQueryXHR, textStatus: string) => any |
headers Property
Specifies an object of additional header key/value pairs to send along with requests using the XMLHttpRequest transport.
Declaration
headers: {
[key: string]: any;
}
Property Value
Type | Description |
---|---|
[key: string]: any | A collections of header key/value pairs. |
Remarks
Note
The client-side dashboard control uses the HTTP Post method 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.
Declaration
getFromServer(
url: string,
data?: Object,
queryOptions?: JQueryAjaxSettings
): JQueryXHR
Parameters
Name | Type | Description |
---|---|---|
url | string | A string containing the URL to which the request is sent. |
data | Object | |
queryOptions | JQueryAjaxSettings |
Returns
Type |
---|
JQueryXHR |
performPostback(url, args) Method
Posts data from the client to the server.
Declaration
performPostback(
url: string,
args: string
): void
Parameters
Name | Type | Description |
---|---|---|
url | string | A string containing the URL to which the request is sent. |
args | string |
postToServer(url) Method
Posts data to the server.
Declaration
postToServer(
url: string,
data?: Object
): JQueryXHR
Parameters
Name | Type | Description |
---|---|---|
url | string | A string containing the URL to which the request is sent. |
data | Object |
Returns
Type |
---|
JQueryXHR |