There is an event from DatatTable called 'xhr.dt'. You can use it in that way.
$('#' + datatableName).on('xhr.dt', function(e, settings, json, xhr){
getAccessMessageWithStatus(json);
}).DataTable({
destroy: true,
'bProcessing': false,
'bServerSide': true,
'ajax':
{
'url': URL,
'data': filters,
beforeSend: function () {
loader.popup('show');
},
complete: function () {
$listContainer.show();
$containerChoiseColumnsFilter.show();
$(".containerRaportButtons").show();
getLastSearches();
getUses();
loader.popup('hide');
}
}
});
You shouldn't use success from ajax attribute because you will overwrite the success function from DataTable. See this piece of code from query.dataTables.js
"success": function (json) {
var error = json.error || json.sError;
if ( error ) {
_fnLog( oSettings, 0, error );
}
oSettings.json = json;
callback( json );
}
You can notice that they have a callback inside this function. This callback triggers the function _fnCallbackFire and this call the event xhr.dt