callback every time the server side query is run
callback every time the server side query is run
I don't always get good data back from the server, but I am always able to include an error message. I pick that message up with a callback, and display it to the user. I have gotten it to work with initComplete, but that only fires when the table is first initialised.
What I need to do is be able to do the same thing, but after the user has typed in some search text, and it comes back sour.
For reference, here is the initComplete callback specifier used when I define the table:
"initComplete": function(settings, json) {
console.log("init complete, error msg: " +json.sErrorMessage);
$("div#ErrorMessage h2").text(json.sErrorMessage);
}
This question has an accepted answers - jump to answer
Answers
Hi,
There are two options here:
1) Use the built in error handling by returning an
error
parameter in the JSON object where the value is what the user should see - by default DataTables will display this in analert()
message to the user. For example the following JSON could be used:2) Use the
xhr
event. This is going to be basically the same as yourinitComplete
, but it is triggered every time DataTables makes an Ajax request to get data.Regards,
Allan