Server side pagination and filter not working v 1.10

Server side pagination and filter not working v 1.10

FireFoxIIFireFoxII Posts: 17Questions: 10Answers: 0

HI and sorry for my english...
I'm using a simple server-side script with a 3 column datatables but I can't get pagination and filter working...

This is my simply datatables setup

<table id="table" class="table table-bordered table-striped">
 <thead>
  <tr>
   <th>id</th>
   <th>cognome</th>
   <th>nome</th>
  </tr>
 </thead>
</table>

......................

  $(document).ready(function() {
      $('#table').DataTable( {
          "processing": true,
          "serverSide": true,
          "ajax":  "scripts/prova2.php"
      } );
  } );   

This is a sample of return data from network in chrome console

{sEcho: 0, iTotalRecords: "1134", iTotalDisplayRecords: "1134",…}
aaData: [["1", "DE SANTIS", "ONOFRIO "], ["2", "FORTUNATO ", "SANDRO"], ["3", "SANSEVERINO ", "ALFONSO"],…]

Seems that server script don't receive any data from client...

Thanks

Answers

  • glendersonglenderson Posts: 231Questions: 11Answers: 29

    Does your .php really handle server side requests? When using serverside, if you monitor the html response and requests, you should see that all the necessary values to generate the SQL is being passed to the ajax php page. How is your page then handling those fields? Most people do not require server side processing. dataTables can handle thousands of rows without ever going to serverside. I find serverSide useful only when I cannot return all my data in a single query. Limiting the display to 100 records or less is highly useful all the time.

  • FireFoxIIFireFoxII Posts: 17Questions: 10Answers: 0

    Yes, now I'm working whitouth server-side but i would to implement this because query on database return lot of data and more every day...
    The datatable become heavy and I must attend lot of time when load...
    My purpose with server-side it's to implement a defer loading...

    I accept other suggestion for what I must do :)

  • allanallan Posts: 63,761Questions: 1Answers: 10,510 Site admin

    sEcho: 0

    That is wrong. sEcho will never be zero - see the legacy server-side documentation:

    sEcho An unaltered copy of sEcho sent from the client side. This parameter will change with each draw (it is basically a draw count) - so it is important that this is implemented. Note that it strongly recommended for security reasons that you 'cast' this parameter to an integer in order to prevent Cross Site Scripting (XSS) attacks.

    Allan

  • FireFoxIIFireFoxII Posts: 17Questions: 10Answers: 0

    Ok, this is my fault...
    But if I set

    "sEcho" => intval($_GET['sEcho'])
    

    I always get the error that $_GET['sEcho'] was unknowed...

  • allanallan Posts: 63,761Questions: 1Answers: 10,510 Site admin

    Are the parameters being sent as GET parameters, or have you configured it as POST? Another possibility is that you are not in fact using the legacy protocol, but the current one. Without a link to the page I'm afraid I'm just guessing.

    Allan

This discussion has been closed.