how to handle Ajax 401 (unauthorized access error) in Jquery datatables?
how to handle Ajax 401 (unauthorized access error) in Jquery datatables?
sangramkapre
Posts: 2Questions: 1Answers: 0
I am using a datatable as follows:
$('#resources_table').dataTable({
"processing": true,
"serverSide": true,
"columns": [
{ "data": "id" },
{ "data": "column1" },
{ "data": "column2" }
],
"ajax": "/resource",
"error": function(reason) {
console.log("error encountered ! ");
// process reason here to know the type of the error
// and then take appropriate action
}
});
Somehow I am not been able to catch error returned from the server. How to access reason
and process error
in serverside processing ajax based datatables?
PS: I am using the latest dataTable version: DataTables 1.10.1
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Use:
There is no
error
option in DataTables top level options list: reference.Allan
Thanks a lot Allan. I realized that 'ajax' options takes one of the 3 types of value: 'string', 'object', and 'function'. I used 'object' (similar to what you mentioned in your answer) to provide a custom 'error' callback.