error handler in scheduler

how do i get error handling in scheduler during load, i am trying to handle server error during load so that scheduler does not end up in infinite loop of loading indicator. is there a way to check what was server response (400, 200 etc) during scheduler load.

i am calling

scheduler.load(“events.action?uid=” + scheduler.uid(), “json”);

i tried call back which works only if server response was successfull, but that does not work when load request fails due to server not being available.

Thanks

Hi,
check this events
docs.dhtmlx.com/scheduler/api__s … event.html
docs.dhtmlx.com/scheduler/api__s … event.html

Thanks but that does not work, have you tried it and see it gives you handle to check if your ajax was successfull.

what i am trying is to:

  1. display loading indicator
  2. Call Scheduler.load
    ===
  3. see if the ajax was success if yes then
    3a. remove loading indicator
    3b. let the scheduler render the data

else if ajax had error status != 200 then
3c. remove loading indicator
3d. display a message to user that something went wrong with remote data provider.

hope this help better understand what i am trying to do so that you can replicate on your end and suggest something that works.

Not trying to be -ve, my experience with this forum so far is post a question and then answer yourself. ( which i like to answer so that someone else can benefit). just giving my feed back so that you can improve this forum experience “only if anyone cares”

anyway enough of my crying…

here is how i got this done, i did it 2 different ways there would certainly a better way than this, till then here it is (fyi i am using json).

solution1:

function ajaxRespHandler(loader){
if(loader.xmlDoc.status == 200){
var jsonData = JSON.parse(loader.xmlDoc.responseText);
scheduler.parse(jsonData.data,“json”);
}else{
alert("ERROR!!! \n \n System Error code: " + loader.xmlDoc.status );
}
}

dhtmlxAjax.get(“events.action?uid=” + scheduler.uid(), ajaxRespHandler);

solution2:

scheduler.on_load = function(loader) {
var evs;
if(loader.xmlDoc.status == 200){
if (this._process && this._process != “xml”) {
evs = this[this._process].parse(loader.xmlDoc.responseText);
} else {
evs = this._magic_parser(loader);
}
scheduler._process_loading(evs);
} else{
alert("ERROR!!! \n \n System Error code: " + loader.xmlDoc.status );
}

this.callEvent("onXLE", []);

};

scheduler.load(“events.action?uid=” + scheduler.uid() , “json”);

Thanks for all those who tried to help ( that is all that matters genuine try)
enjoy keep sharing.

Hello,
the onLoadError event fires if an ajax loading or parsing of data fails.
In case all gone as expected - onXLE event will fire.

So the firing of onXLE event is a reliable enough indicator that the response is successful.
The expected approach for handling ajax loading is using following three events

  1. onXLS - ajax started -> display an indicator
  2. onXLE - ajax ended, all good, the data is parsed -> hide an indicator
  3. onLoadError - something is bad, the data is not parsed -> hide an indicator, show some error message

If this scenario does not work for you - please elaborate.

Hi, Aliaksandr,

may be i was not clear enough, will use your thought process

  1. onXLS - ajax started -> display an indicator (does fires)

  2. onXLE - ajax ended, all good, the data is parsed -> hide an indicator (does not fire)

  3. onLoadError - something is bad, the data is not parsed -> hide an indicator, show some error message (does not fire).

Scenario that you should be able to replicate on your end.

  1. create a scheduler that loads data from remote server (or from local host)
    use Scheduler.load…

  2. try to take off the localhost/remote server that is acting as source for the scheduler

and then please tell me if 2) and 3) works for you.

Thanks

My mistake, in case of ajax error all handlers will fire, in following order:
onXLS - onLoadError - onXLE

in case of correct loading it will be:
onXLS - nXLE

docs.dhtmlx.com/scheduler/snippet/cad6725e - click on ‘Ajax’ button to reproduce load error. It will try to load data from not existing url, so you’ll get quite genuine error