Server side processing doesn't redraw table

Server side processing doesn't redraw table

dymissydymissy Posts: 2Questions: 0Answers: 0
edited April 2014 in DataTables
Hello,
I'm using DataTables in its latest version on ZF1.1 application. At the beginning I used the library without server side processing but actually the number of rows are about 2k so I decided to use the library with server side processing and this is the code I'm using:
[code]
var oTable = $('.datatableajax').dataTable({
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "/quote/fetch",
"aaSorting": sorting,
"aoColumns": cols,
"iDisplayLength": 100,
"oLanguage": {
"sSearch": "Cerca in tutte le colonne:"
}
});
[/code]

The server returns a valid JSON (checked and validated with JSON lint), something like the following:

[code]
{
"sEcho": true,
"iTotalRecords": 100,
"iTotalDisplayRecords": 51,
"aaData": [
[
"",
"0",
" ",
"543",
"2014",
"2014-04-17",
"2014-04-17",
"My Company",
"1218.73",
"John Doe",
"Inviato",
"",
" "
]
//other results.....
]
}
[/code]

When I load the page the table is drawed fine without problems and with correct data but when I try to filter or order the table, so in other words when I launch a new Ajax call that requires to redraw the table with new data, the table doesn't work and the message "Processing..." doesn't disapper.

I checked in Chrome Network tab the XHR call and it returns a valid JSON with valid data filtered so the server queries work fine. Anyway I can't figure out why the "Processing..." message is still displayed and the table contains old data. I even checked the Chrome console and no errors are logged.

Unfotunately the application is password protected so I cannot provide a working link.

Any suggestion about the nature of the issue?

Thanks

Replies

  • allanallan Posts: 61,672Questions: 1Answers: 10,098 Site admin
    > "sEcho": true,

    That's not an expected server-side processing response. From the documentation ( http://datatables.net/usage/server-side ):

    > 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.

    I very much suspect that is the issue.

    Allan
  • dymissydymissy Posts: 2Questions: 0Answers: 0
    edited April 2014
    Hello Allan,
    you're right. The value was returned as boolean value, that was the issue.

    Solved! Thanks a lot! :)
This discussion has been closed.