Cannot catch session expire
Cannot catch session expire
Hi all,
I'm using a server side processing and I want to treat session expire behavior but I'm not able to do this.
I receive this error:
jquery.dataTables.min.js:40 Uncaught TypeError: Cannot read property 'length' of undefined
at wb (jquery.dataTables.min.js:40)
at jquery.dataTables.min.js:37
at i (jquery.dataTables.min.js:35)
at Object.success (jquery.dataTables.min.js:36)
at l (app.js?v=1.0:1)
at Object.fireWith [as resolveWith] (app.js?v=1.0:1)
at E (app.js?v=1.0:1)
at XMLHttpRequest.<anonymous> (app.js?v=1.0:1)
I've tried this without success:
$.fn.dataTable.ext.errMode = function ( settings, helpPage, message ) {
console.log(message);
}
The above function is never triggered.
Also the error function is never triggered and it does not write in console:
$('#table').DataTable({
ajax: {
dataType: "JSON",
type: "POST",
url: url,
data: [],
async: true,
error: function (xhr, error, code)
{
console.log(xhr);
console.log(code);
}
}
The global configuration for ajax works for all cases except datatables:
$.ajaxSetup({
statusCode: {
401: function(){
location.href = "/";
},
419: function(){
location.href = "/";
}
}
});
I'm using https://cdn.datatables.net/1.10.19/js/jquery.dataTables.min.js
Any idea?
Replies
Send back a JSON structure such as:
which should do it.
Allan
Thanks Allan,
It works fine but now I have an automatic alert with the message "Session expired". How should I do to avoid to show it?
Don't return the
error
parameter if you don't want it to show an error message.Allan