AjaxRemoteServiceOptions Interface
Provides options for customizing the AjaxRemoteService.
Declaration
export interface AjaxRemoteServiceOptions
Remarks
The Ajax remote service is a default IRemoteService‘s implementation that used to exchange information between client and server sides. You can get different information from a server (data sources, export information, a dashboard model), get a dashboard request time, pass custom HTTP headers, and so on.
The code samples below show how to configure the client: set the server’s url and pass a custom Authorization header. Note that the endpoint value consist of a base URL where the Web Dashboard’s server side is hosted and a route prefix - a value that is set in the MVC / .NET Core MapDashboardRoute properties.
<script>
window.onload = function () {
DevExpress.Dashboard.ResourceManager.embedBundledResources();
var dashboardControl = new DevExpress.Dashboard.DashboardControl(document.getElementById("web-dashboard"), {
endpoint: "{baseURL}/api/dashboard",
ajaxRemoteService: {
headers: {
'Authorization': 'AuthToken123'
}
}
});
}
</script>
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 | Description |
---|---|
(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
complete?: (jqXHR: JQueryXHR, textStatus: string) => any
Property Value
Type | Description |
---|---|
(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
headers?: {
[key: string]: any;
}
Property Value
Type | Description |
---|---|
[key: string]: any | A collection 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 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.