error managment
error managment
hi all
I'd like to catch some error.
I have a table with data opened on screen, go to eat or else, and when come back later click on edit...
Editor will open but data is not yet connected because data cookie expiration (or other case like network disconection, ...).
Each time I get data using ajax, the php file called verify if session is active using a php function. If not, this function try to redirect href to authentification page and return false.
So when opening editor, an ajax load is launched, and when success, response is not ajax formatted, (because php try to set href to auth page). so error is : ajax response not formatted correctly,
If setting errMode to alert, I get the
DataTables warning: table id=SecDonnees - Invalid JSON response. For more information about this error, please see http://datatables.net/tn/1
If I set the errMode to none I have no message
In both case, editor will open
changing some editor values, and then submit changes... and I get the submitError event, then deal with this... returning to auth page. OK
So I think setting errMode to none and get the error myself, but
when errMode is set to none I can't get a message... (breakpoint not reached)
$.fn.dataTable.ext.errMode = 'none'
$('#donnees').on( 'error.dt', function ( e, settings, techNote, message ) {
// breakpoint
console.log( 'Error : ', message );
} )
Where am I wrong ?
A similar way is How to manage timeout and go to specific page not regarding what program is doing (both in an editor or table page...)
Thanks for help
Regards
This question has an accepted answers - jump to answer
Answers
The situations you describe are outside the scope of DataTables. I don't really understand what you are hoping to achieve here.
hi @tangerine
Thanks for answer
I just want to be sure when user edit or add or delete a row than data is accessible , and if not display a message and go to login form...
As I said, if a table is displayed and user go away for a moment, when coming back the data will not be accessible because at data call (ajax) a cookie validation is done.
If delay is expired, data will not be and I'd like to tell user it is, before to open editor (not on submiterror event) for example at click on edit button (or both edit / add/ remove action) or row change or ...
Is there a way to globally set this ?
the error is throw at success result of ajax call, that message is tn1...
Where errMode is set to alert, mesage is displayer in alert...
Where errMode is set to throw, the message is in js console....
If errMode is set to none, I can't catch the error (or I miss something) to manage it...
The oder way should be to verify cookie onPreopen and on select / deselect, ........
I hope a more global system should be....
Regards
Bob
Hi Bob,
DataTables always expects a valid JSON response - even if there is an error somewhere. Could you perhaps have the server return:
And then use
xhr
to check for theerror
parameter. If it is there, then do awindow.location.href = '/login';
(or whatever)?Regards,
Allan
Thanks all