Hello
How can I report an error to the user if an error occurs while sending the data?
var dp = new dataProcessor("/senddata");
dp.getSyncState();
dp.setTransactionMode("JSON");
dp.init(scheduler);
The errors are displayed in the console, the user does not see them.
Thank you
ciao Thomas
You can use onAfterUpdate event of dataprocessor
dp.attachEvent("onAfterUpdate", function(id, action){
if (action === "error")
alert("There was error during data saving");
});
Hi Stanislav,
Thank you. I have the code built in. he is not working yet.
I have generated a 500 error. This is displayed in the console. There is no answer about the error to the user.
How can I improve that?
var dp = new dataProcessor("/senddata");
dp.attachEvent("onAfterUpdate", function(id, action){
if (action === "error")
alert("There was error during data saving");
});
dp.getSyncState();
dp.setTransactionMode("JSON");
dp.init(scheduler);
There are two levels of error handling, the above code will catch the case when server-side have some error during data saving, but still returns a valid message with error info.
If some critical issue occurs, and server reports error with status code you can use the onAjaxError handler, which will fire for all data communication errors
dhx4.callEvent("onAjaxError", function(xhr, url){
alert("Some error for "+url);
});
That does not want to work. Do you have an example?
An error returned by Ajax appears either in the console or as an alert, which I control via the parameter scheduler.config.ajax_error
dhtmlxscheduler uses older data loading API, and error can be caught with code like next
dhtmlxError.catchError("LoadXML", function(type, name, params){
var xhr = params[0];
alert(xhr.responseText);
});