Using data.draw in 'Ajax : function(data, callback, settings)' does not match pager

Using data.draw in 'Ajax : function(data, callback, settings)' does not match pager

pingcrosbypingcrosby Posts: 29Questions: 4Answers: 1

Can someone explain the correct use of the parameter data.draw. I thought it would match the current page selected by the pager. But it just seems to increment.

The following example will demonstrate.

  1. Generate any table set it to serverside and the following ajax : function() dt:ajax
  2. The table will show an empty table with "showing 1-10 of 50 entries", [prev] [1] [2] [3] [4] [5] [next] buttons
  3. As you press the pager the alert will show 1,2,3,4,5, but then pressing prev will show 6,7,8,9,10 etc..
    the param data.draw always increments. It does not match the page being requested.
 serverSide: true,

 ajax: function (data, callback, settings) {
    
        alert(data.draw); // data.draw always increases even if you select [previous] 
     
        var r = {};
        r.draw = data.draw;   
        r.data = {};
        r.recordsTotal = 50;
        r.recordsFiltered = 50;
  
        callback(r);
}

Replies

This discussion has been closed.