ajax + paging
ajax + paging
I just built a page using datatables 1.10.8 + ajax. The ajax source returns a 400 error if something fails and I have an error callback in my datatables definition which appears to be called fine. However when an error occurs paging doesn't seem to work right. The UI still correctly shows me on the previous page but something must think I am on the new page. If I click on the page that I was trying to go to, nothing happens. If I click the next button it takes me two pages ahead as if the previous call worked and I am trying to go to the next page after that. Any idea what I might be doing wrong or now I can correct this?
This is my datatables definition
$('#results').on('page.dt', function() { showMask(); }).DataTable({
ordering: false,
bLengthChange: false,
deferLoading: 0,
serverSide: true,
processing: false,
dom: 'frtip<"toolbar">',
ajax: {
type: 'POST',
url: 'search.php',
data: function(d) {
// ...
},
dataSrc: function(json) {
hideMask();
var data = [ ];
// ...
return data;
},
error: function(response) {
hideMask();
// ...
return false;
}
}
});
Replies
Hi,
The problem with suppling your own
error
handler is that it overrides DataTables'. The same applies to thesuccess
handler. I plan to make it possible to do that, but haven't done so for 1.10.8.What you need to do is listen for the
xhr
event and take action on that.Allan