When working with dataTables, keep in mind that it utilizes the ajax success
callback internally. Attempting to override this can lead to issues. However, dataTables offers its own dataSrc
callback which is triggered within the success handler. This provides an opportunity to modify the response before any data is populated:
this.dtOptions = DTOptionsBuilder.newOptions()
.withOption('ajax', {
dataSrc: function(json) {
//success!
console.log(json);
return json
},
type: 'POST',
contentType: 'application/json',
processData: false,
....
Check out the demo -> http://plnkr.co/edit/94EWyDanIawCJJgyagiy?p=preview
In the provided demo, you'll notice another option in the ajax complete
callback:
ajax : {
complete: function(jqXHR, textStatus) {
console.log(jqXHR.responseText)
}
..
}