call a function in success of datatable ajax call
ajax, datatables, javascript, jquery
Solution
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" }
]
} );
Problem
Is that possible to invoke a javascript function in success of datatable ajax call. Here is the code am trying to use, ``` var oTable = $('#app-config').dataTable( { "bAutoWidth": false, "bDestroy":true, "bProcessing" : true, "bServerSide" : true, "sPaginationType" : "full_numbers", "sAjaxSource" : url, "fnServerData" : function(sSource, aoData, fnCallback) { alert("sSource"+ sSource); alert("aoData"+ aoData); $.ajax({ "dataType" : 'json', "type" : "GET", "url" : sSource, "data" : aoData, "success" : fnCallback }); } ``` is it possible to have something like, ``` success : function(){ //.....code goes here } ``` instead of "success" : fnCallback ------> which is last line of AJAX call. In this function I would like to check a value send from server side.