If you want to refresh the events it is better to use .events.list array instead of .events.add() method. Adding events one by one using .events.add() works too but it is slower (it refreshes the scheduler every time).
An example using DayPilot.request():
function loadEvents() {
DayPilot.request("backend_events.php", function(result) {
var data = eval("(" + result.responseText + ")");
dp.events.list = data;
dp.update();
});
}
An example using jQuery:
function loadEvents() {
$.post("backend_events.php",
function(data) {
dp.events.list = data;
dp.update();
});
}
If you want to clear the existing events use this:
dp.events.list = [];
// call update if you want to display the emtpy scheduler
dp.update();