The events.load() method loads events from a URL using an HTTP GET or POST request, depending on eventsLoadMethod. The endpoint must return a JSON array of event records that follow the DayPilot.Event.data structure.
Declaration
DayPilot.Scheduler.events.load(url[, success[, error]])Parameters
url(string) - URL of the API endpointsuccess(function) - success callbackerror(function) - error callback
Notes
For GET requests, the Scheduler adds the current view start and end values as query string parameters.
/getEvents?start=2025-06-15T09:00:00&end=2025-06-15T13:00:00Use eventsLoadMethod to switch the request method to POST.
For POST requests, the current view start and end values are sent as a JSON object in the request body (since version 8.1):
{"start": "2025-06-15T09:00:00", "end": "2025-06-15T13:00:00"}The Scheduler is updated automatically after a successful HTTP call. You can cancel the client-side refresh by calling args.preventDefault() in the success callback.
Success Callback
function success(args) {}The success callback is only executed if the data is successfully received from the URL and it can be parsed as a JSON array.
Arguments:
args.preventDefault()- cancels the automatic Scheduler refreshargs.data(array) - event data received from the server
Error Callback
function error(args) {}The error callback is executed for HTTP responses except status codes 200/304, and when JSON parsing fails.
Arguments:
args.exception(object) - JSON data parsing exceptionargs.request(XmlHttpRequest) - the request object used for the AJAX call
Example
Minimal call:
dp.events.load("/getEvents");With callbacks:
This example loads events from /getEvents. When eventsLoadMethod is set to "POST", the current date range is sent in the request body as start and end.
dp.eventsLoadMethod = "POST";
const success = (args) => {
dp.message("Events loaded");
};
const error = (args) => {
dp.message("Loading failed.");
};
dp.events.load("/getEvents", success, error);Sample data returned from /getEvents:
[
{
"id": 1,
"start": "2025-01-01T09:00:00",
"end": "2025-01-01T13:00:00",
"text": "Event 1",
"resource": "A",
"cssClass": "my-event",
"resizeDisabled": true
},
{
"id": 2,
"start": "2025-01-02T09:00:00",
"end": "2025-01-02T13:00:00",
"resource": "B",
"text": "Event 2"
}
]See Also
DayPilot.Scheduler.eventsLoadMethod
Event Loading [doc.daypilot.org]
Availability
Availability of this API item in DayPilot editions:
| Product | Lite | Pro |
|---|---|---|
| DayPilot for JavaScript |
DayPilot