Handling session timeouts and 400/500 http errors

I’m using DhtmlxScheduler in a application that requires users to be logged on. Sometimes they’ll leave the scheduler screen open for a long time and try to insert an event - it won’t work because the session has expired and in the background the ajax response was a 302 redirect to a login page - but dhtmlx won’t alert the user of the malformed response, even if I issue a 500 or 400 error.

Is it possible to catch a malformed response and alert the user that the event might not been saved? Or, how to redirect user to login page depending on the response from the server?

I forgot to say that a solution that I thought of was doing a check before events are saved, but I would need a handler for delete/change/create, and there may be multiple events for each (like onEventSave and onBeforeEventChanged).

Just as a suggestion, you should implement an event that fires before requests to the server (a general on onBeforeSave) that applies to any operation.

I’m using the connector supplied with DhtmlxScheduler, and managed to force an error while trying to save/create a event by giving db user only select privileges.

The connector response is:

<?xml version='1.0' ?><data><action type='error' sid='1324' tid='1324' ></action></data>

Even with this response, there’s no indication of an error to the user and the new/changed event looks like it has been saved (only a refresh would show otherwise).

a) there are onBeforeUpdate and onBeforeDataSending events which fire before any server side saving operation. Those are events of the dataprocessor (dp.attachEvent), not the scheduler.

docs.dhtmlx.com/doku.php?id=dhtm … foreupdate
docs.dhtmlx.com/doku.php?id=dhtm … atasending

b) There is onAfterUpdate event (again, it is event of the dataprocessor) which will fire after each operation and from which you can check status of operation. ( it will be “error” for the error response )

docs.dhtmlx.com/doku.php?id=dhtm … fterupdate

c) above works for the valid xml response with error status. For the case when some error occurs and response is not a valid xml you can use dhtmlxError object - something like

dhtmlxError.catchError("ALL", function(){ /* will be called for all loading errors */ });