Issue with .load()

When I use the .load() to get my data, I use a callback on the Load2 to retrieve IDs and then put them on readonly (+coloring).
What happens is this : the callback gets the IDs from one or another .load() randomly… So, sometimes, the coloring and readonly are triggered for the Load1 instead of the load2, and this is random, I can’t figure out why this happens.

$(function() {

scheduler.attachEvent("onLightbox", function (id){
    console.log(scheduler.getEvent(id));
});

scheduler.config.lightbox.sections = [ 
    {name: "prestation", height: 40, type: "select", map_to: "type_code", options: types},
    {name: "related", height: 40, type: "select", map_to: "employee_id", options: employees},
    {name: "time", height: 72, type: "time", map_to: "auto"},
    {name: "note", height: 130, map_to: "note", type: "textarea"}
];

// Load1
scheduler.load(url+"/attendances/list", “json”);

// Load2
scheduler.load(url+"/calendar/holidays/list", "json", function(){
    for (var i in this._events){
        scheduler.getEvent(i).readonly = true;
        scheduler.getEvent(i).color = "#ccf1ff";
        scheduler.updateEvent(i);
    }
}); 

});

Hi,
scheduler.load works asyncronously and requests will go concurrently if it is called several times. There is no way to tell which request will be completed first.
In order to make code work, you need to run callback after all requests are completed. This can be done either by loading data manually (send ajax/promise then parse loaded data into scheduler and call callback after all requests are done), or count completed loading requests using api events so you could tell when all pending requests are done, or simply call loading successively - call load2 from load1 callback
docs.dhtmlx.com/scheduler/api__s … event.html
docs.dhtmlx.com/scheduler/api__s … event.html