call a function in success of datatable ajax call
You can use dataSrc :
Here is a typical example of datatables.net
var table = $('#example').DataTable( { "ajax": { "type" : "GET", "url" : "ajax.php", "dataSrc": function ( json ) { //Make your callback here. alert("Done!"); return json.data; } }, "columns": [ { "data": "name" }, { "data": "position" }, { "data": "office" }, { "data": "extn" }, { "data": "start_date" }, { "data": "salary" } ] } );
You can use this:
"drawCallback": function(settings) { console.log(settings.json); //do whatever },
The best way I have found is to use the initComplete method as it fires after the data has been retrieved and renders the table. NOTE this only fires once though.
$("#tableOfData").DataTable({ "pageLength": 50, "ajax":{ url: someurl, dataType : "json", type: "post", "data": {data to be sent} }, "initComplete":function( settings, json){ console.log(json); // call your function here } });