0

I am working with JQuery DataTable and fetching data from server and it is working fine except of Pagination. when I click next it fetches next result but when I click previous then also it returns next result not previous. I have debugged the code and found that sEcho is getting incremented by one each time. Also whenever I redraw Table it send request on server and fetching next result.

my code is for updating sEcho :

sEcho = request.getParameter("sEcho");

What is wrong not getting.

My DataTable code is

$lmTable = $('#datatable').dataTable( {
         "bProcessing": true,
        "bServerSide": true,
        "sAjaxSource": url,

        "iDisplayLength": 10,
        "bFilter":true,
        "bSort": false,
});
1
  • could you add the datatables definition? The code were you initialize the table. Commented Mar 8, 2014 at 12:28

1 Answer 1

2

on every request to the server, the value of sEcho is updated and sent to the server.
i.e. on Next, Previous button clicks too.

This sEcho acts like a token to make a reference with the returned values.

So while returning the array via the url, make sure the same sEcho value is retuned.

Eg: Form data

sEcho:1
iColumns:7
sColumns:
.....

Returned values should be like -

{"sEcho":1,"iTotalRecords":3,"iTotalDisplayRecords":3 ......

The sEcho sent and sEcho received should be same. Next time may be 2 is sent, so 2 should be received.

I hope it helps someone.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.