The DayPilot.Http.ajax() method makes an HTTP request to the specified URL.
The syntax and behavior is inspired by jQuery.ajax(). However, the default POST body format is JSON.
Available in DayPilot Pro for JavaScript since version 2018.2.3223. In previous versions, it is available as DayPilot.ajax().
This method is static.
Declaration
DayPilot.Http.ajax(options);Parameters
options.url(string) - URL of the HTTP requestoptions.method("POST"|"GET"|"PUT"|"DELETE") - request method. The default value is"GET". Since 2020.3.4578, if the method is not specified andoptions.datais present,"POST"is used.options.data(optional) - request body. If the type ofoptions.datais"object", the value is serialized using JSON.stringify().options.contentType(string, optional) - request body content type. The default value is"application/json"ifoptions.datais an object, or"text/plain"for other types.options.success(optional) - success event handleroptions.error(optional) - error event handler
Success Callback
The success callback is executed when the response is received with HTTP status code 200, 201, 204, or 304.
Arguments:
args.request-XMLHttpRequestobject used for making the requestargs.data- event data received from the server, converted from JSON to object usingJSON.parse()
Error Callback
The error callback is executed when the response is received with an HTTP status code other than 200, 201, 204, or 304.
Arguments:
args.request-XMLHttpRequestobject used for making the request
Example
DayPilot.Http.ajax({
url: "/events",
success: (args) => {
console.log("Data received:");
console.log(args.data);
}
});
DayPilot