On ajax error: fnCallback for datatables 1.10
On ajax error: fnCallback for datatables 1.10
babablacksheep
Posts: 41Questions: 23Answers: 0
Previously I was using fnCallback if ajax error happened, in fnCallback I just used to return
empty array.
How Can I do same in datatables 1.10 so that on ajax error , I set table`s data empty and hide processing div as well, this was very easy with fncallback?
"fnServerData": function (sSource, aoData, fnCallback) {
$.ajax({
"type": "GET",
"url": sSource,
"success": function (json) {
},
"error": function () {
fnCallback({
"data": []
});
}
});
}
Now I am using datatables 1.10
table.dataTable({
//http://datatables.net/reference/option/
"ajax": {
"url": "user.json",
"type": "POST",
"dataSrc": function (json) {
return json.data;
},
"error": function () {
var data = {
"data": []
};
return data ;
}
},
});
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Hello,
I see that fnServerData , sServerMethod , sAjaxSource and sAjaxDataProp are still available in datatables 1.10 . Are these going to be deprecated in future ? if not why are these not included in new documentation
They will be removed in v2 - but development for that hasn't started yet, and likely won't for a long time to come.
Because the new style camelCase syntax is preferred in the new documentation and I didn't want to confuse things by showing duplicate functionality using different names.
Use
ajax
as a function to make an Ajax call as you were before.Allan