title: Ajax result rows - how to paginate?
body: <p>How to paginate my ajax result rows in codeigniter . I want to display my ajax result which would be 10-20 rows in batch  of 4 or 5 rows per page . Hwlp me through. It is not Ajax pagination but it is ajax paginating in an ajax call. Thank you</p>
  
  <p>This is my view file : </p>
  
  <pre><code> &lt;script type="text/javascript" src="https://cdn.datatables.net/v/dt/dt-1.10.12/datatables.min.js"&gt;&lt;/script&gt;
  &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"&gt;    &lt;/script&gt;
  &lt;script&gt;
   $(document).ready(function(){
   $("#getreport").click(function(){
   var fromdate = $('#date1').val();
   var todate = $('#date2').val();
   $("#header").css("visibility", "visible");
   // $("#bodycontent").empty();
   // $("#bodycontent").html('&lt;div id="subcontent"&gt;&lt;/div&gt;');
   data =
  {
  "from"  : fromdate,
  "to" : todate
  } 
  $.post('&lt;?=site_url("Report/managecustomers_report"); ?&gt;', data ,function (data) {
  $('#datatable').dataTable({
      data : data
      // columns : [
      // { 'data' : 'picture'},
      // { 'data' : 'customername'},
      // { 'data' : 'contactperson'},
      // { 'data' : 'mobilenumber'},
      // { 'data' : 'phone'},
      // { 'data' : 'email'},
      // ]
  });
  });     
  });
  });
  &lt;/script&gt;
  &lt;div class="table-responsive"&gt;
      &lt;table class="table allcp-form theme-warning fs13"&gt;
          &lt;thead&gt;
              &lt;tr class="bg-light"&gt;
                  &lt;th class=""&gt;Image&lt;/th&gt;
                  &lt;th class=""&gt;Customer Name&lt;/th&gt;
                  &lt;th class=""&gt;Contact Person&lt;/th&gt;
                  &lt;th class=""&gt;Mobile Number&lt;/th&gt;
                  &lt;th class=""&gt;Phone&lt;/th&gt;
                  &lt;th class=""&gt;Email&lt;/th&gt;
  
              &lt;/tr&gt;
          &lt;/thead&gt;
      &lt;/table&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>My controller : </p>
  
  <pre><code>public function managecustomers_report()
  {
  
   $query = $this-&gt;Reportmodel-&gt;customerreport_select($this-&gt;input-&gt;post('from'),$this-&gt;input-&gt;post('to'));
   $data = $query['records'];
    $this-&gt;output-&gt;set_content_type('application/json');
   $this-&gt;output-&gt;set_output(json_encode($data));
   return $data;
  }
  </code></pre>
  
  <p>My model file :</p>
  
  <pre><code>public function customerreport_select($date1,$date2)
  {
  $this-&gt;db-&gt;where('date &gt;=', $date1);
  $this-&gt;db-&gt;where('date &lt;=', $date2);
  $query=$this-&gt;db-&gt;get('customers');
  $row = $query-&gt;result();
  print_r($row);
  return array(
  'records' =&gt; $row,
  'count' =&gt; count($row));
  }
  </code></pre>