How to redirect ajax callback to my callback function?
How to redirect ajax callback to my callback function?
Hello. I am using the custom data get function
function ajax( data, callback, settings )
so that I can do a custom asynchronous callback using my application and then give the retrieved data to data tables. Data Table's ajax function expects a JSON object in the callback parameter. How can I let data tables know that my asynchronous procedure has finished and give it the retrieved data to display it? If possible, please give me a short example in Javascript.
Thank you very much
This question has an accepted answers - jump to answer
Answers
dataTables uses the normal jquery ajax methods, so you can have a "complete": option.
After the ajax method completes, I call a function to swap all the checkboxes for a fancy checkbox.
But, if you don't mind a suggestion ... Why would you not simply change the ajax: to call either your function or URL and return json formatted data instead? That is the best and easiest way in my opinion to get exactly what you want pushed into the table itself.
Thank you very much for your reply. I actually solved the problem using the function
ajax( data, callback, settings )
. Within this function I assigned the callback to another global function in my code, let's say myFunction(), and thus myFunction() was overwritten by DataTables callback function. Then whenever my asynchronous procedure retrieved the data it could call myFunction() and that would update the table with the retrieved data.