I rarely if ever do javascript so I'm fairly certain that this is either a misconfiguration or something I'm missing.
I'm using Datatables v1.10.7. I have a table that has all the necessary required pars, a thead, tfoot and a tbody. In that order.
I'm using serverside processing to get some data and populate the table.
Due to the fact that I want to add some other things not related to datatable but related to the data that it gets I wanted to have a callback function.
$('#target-list-li').DataTable({
processing: true,
serverSide: true,
pageLength: 100,
ajax: {
url: ajax_url,
success: function(data) {
// Do other stuff here
return data;
}
},
columns: [
{
data: 'trans_source_id',
render: function (data, type, row) {
var html = '';
html += '<input type="checkbox" id="check-' + row.trans_source_id + '" ';
},
orderable: false
},
// more columns would go here but I've removed them since it's irrelevant to the question
});
The "problem" or rather misunderstanding of it works probably, is with this bit of code success: function(data).
I expected to be able to do some work with the data and then return the data. Do note that I'm not altering the original data in anyway, I just want to extract some information from it.
success: function(data) {
// Some some stuff here
return data;
}
However that doesn't work at all. Even if I simply return the data the table won't get populate. It fact, it simply hangs on the ajax call. It does get completed, but nothing gets populated.
The recommended go to option for ajax apparently is dataSrc. The documentations says so
dataSrc: function(data) {
return data;
}
That does "sort of" work, the table gets populated with no data, at least it's an improvement from the success.
This is how my table looks with the dataSrc attribute.
The documentation is vague at best regarding this, or at least I can't seem to find something relevant for my problem.
What I expected to happen was: Make the ajax call, use the data for some callback while not altering the original in anyway. Do my things, return original data and that's that.
Clearly that's not the case here.
If anybody can point me in the right direct here I'd appreciate it.


dataSrcif you have to modify response before passing it to datatable. If you are not modifying data then just do"ajax": { "url": ajax_url, "type": "POST" }