Problem with loading json data

Problem with loading json data

RosenRosen Posts: 1Questions: 0Answers: 0
edited July 2012 in General
Hello,

I'm using datatables since one year and I have really strange problem

The page I'm making now is here:
http://l5pro.com/cp/keywords_stats_google.html

I'm trying to load the data with ajax request and load it in json format, but data grid is just saying "processing" and that's all.
I checked response with Firebug and data is ok.

Actually the php code behind is used with a little bit older version of datatables and it's working fine.

Can you help me what could be the problem with this?

JS for datatables:
[code]
oTable = $('#dt_e').dataTable( {
"sPaginationType": "full_numbers",
"bProcessing": true,
"bServerSide": true,
"sPaginationType": "bootstrap",
"sDom": "<'row'<'span6'l><'span6'f>r>t<'row'<'span6'i><'span6'p>>",
"sAjaxSource": "lib/datatables/server_side.php",
"sDom": 'T<"clear">lfrtip'
} );
[/code]

Thanks!

Replies

  • allanallan Posts: 63,538Questions: 1Answers: 10,476 Site admin
    Hi,

    I'm almost 100% certain that the problem is with the sEcho value in your JSON return. Specifically it is currently:

    > "sEcho":0

    You _must_ return the value of sEcho that DataTables sends to you on each request, otherwise things won't work (like here).

    What sEcho basically is a a draw counter. Because of the async nature of Ajax you might make two Ajax requests, but the second one could come back from the server before the first! If that were to happen then DataTables would get confused and draw the wrong page. This sEcho parameter is used to stop that from happening.

    sEcho (despite the daft 's' prefix) is an integer and should be cast to an integer on the server (intval() in PHP) - this is a security measure to stop XSS attacks against the site!

    Regards,
    Allan
This discussion has been closed.