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\').dataTa
"success" : function(data){
//do stuff here
fnCallback(data);
}
For datatables 1.10.12.
$('#table_id').dataTable({
ajax: function (data, callback, settings) {
$.ajax({
url: '/your/url',
type: 'POST',
data: data,
success:function(data){
callback(data);
// Do whatever you want.
}
});
}
});
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" }
]
} );
This works fine for me. Another way don't work good
'ajax': {
complete: function (data) {
console.log(data['responseJSON']);
},
'url': 'xxx.php',
},