Editor.ajax.error doesn't catch http errors i.e. 401 etc.
Editor.ajax.error doesn't catch http errors i.e. 401 etc.
Vyacheslav
Posts: 70Questions: 27Answers: 0
I try to catch 401/403 error in Editor on delete but it seems it doesn't work ...
See console at https://datatbl.herokuapp.com/users
Everything works fine with basic grid. On Tab-3 I return 401 on
ajax: { url: 'users.json', error: function (res) { console.log('Tab-3.Status: ' + res.status); }}
and the error-event is triggered.
On Tab-1 I use Editor and return 401 on delete, BUT neither datatable nor editor did not catch the error-event.
BTW: Also doesn't work (:
$.fn.dataTable.ext.errMode = function ( settings, helpPage, message ) { console.log('$.fn.dataTable.ext.errMode: '+message); };
Could anyone help me?
This question has an accepted answers - jump to answer
Answers
I'm not entirely sure I understand the issue, or perhaps more specifically what you want to do. You want to handle the 401 return using some custom code? If so, use the
statusCodeoption of the$.ajaxobject - which is basically all thatajaxis and specify your custom function for a 401 return.Allan
Hi Allan,
I've simplified the example. The problem is that Editor's ajax doesn't detect HTTP-errors.
How to reproduce:
Go to https://datatbl.herokuapp.com/err401
On the first retrieve I return 401 error and Datatable detects it fine - we see an alert.
Create a new row and then delete it. On delete I also return 401 error and expect to see an alert as on step 2, but nothing happens.
BR,
Vyacheslav
Thanks for the link - the issue is that the
errorproperty needs to be part of the Ajax object used. Since you have it broken into three crud components in Editor, it needs to be in those objects - e.g.:I would add a warning about defining your own
erroroption - it will override the Editor default and thus Editor will not be able to trigger any events. I would suggest usingsubmitErrorrather than defining theerroroption.Allan
Thank you for the clarification!
submitError works perfect!