Stuck on Processing

Stuck on Processing

vinit9vinit9 Posts: 20Questions: 1Answers: 0
edited November 2012 in General
Hey all I'm back .. I keep getting a error with sEcho being undefined and not displaying anything in my tables.

This keeps getting stuck on processing but I used JSONLint to check if my JSON is valid and this came up as true. I'm unsure what I may be doing wrong here?

I've recived help for the coding from a previous user but I think this is my final hurdle? Hope someone can help!

Thanks!

Replies

  • jefffan24jefffan24 Posts: 18Questions: 0Answers: 0
    Can you post your JSON that is returned?

    I think its because your not returning sEcho in the JSON. When datatables sends a request to your server it sends sEcho, you need to send this back with the JSON.

    [code]
    $data = array(
    'sEcho' => intval($_GET['sEcho']),
    .... // the rest of your array returned
    );

    echo json_encode($data);
    [/code]
  • vinit9vinit9 Posts: 20Questions: 1Answers: 0
    Sorry for the delay in replying I wasn't at my station;

    I've entered the echo statement that you've posted above and nothing changed on my screen still coming up as processing ..

    I then went into Inspect Element > Network > XHR;
    Double clicked on the file linked and the following can be seen for the sEcho;

    {"sEcho":0,"iTotalRecords":"3","iTotalDisplayRecords":"3","aaData":[]}{"sEcho":0,"iTotalRecords":"3","iTotalDisplayRecords":"3","aaData":[["13","2012-11-01 16:52:01","6","satnav","3","15","Cool"],["14","2012-11-01 17:16:22","6","sata","3","104234324","7"],["15","2012-11-02 17:43:16","2","GPS","231","15111989",""]]}
  • allanallan Posts: 63,529Questions: 1Answers: 10,473 Site admin
    > "sEcho":0

    sEcho should never ever be zero. See: http://datatables.net/usage/server-side

    Allan
  • vinit9vinit9 Posts: 20Questions: 1Answers: 0
    Yeah that's what I thought too but I don't get how I can solve this problem? I'm a total noob to this situation so any help to get it working would be great
  • allanallan Posts: 63,529Questions: 1Answers: 10,473 Site admin
    Just do as the documentation suggests :-)

    > 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
  • vinit9vinit9 Posts: 20Questions: 1Answers: 0
    Got it working at the end. Needed help though as I'm still new to this but it works fine now .. Trying to work on the filtering columns another few sleepless nights ahead I guess. Thanks for the help though allan.
  • girishmrgirishmr Posts: 137Questions: 0Answers: 0
    Vineet,
    I thought you had this solved y'day. Do you still have a problem??
  • vinit9vinit9 Posts: 20Questions: 1Answers: 0
    Hi Girishmr, This problem is solved! I don't know how to change this to solved?
  • allanallan Posts: 63,529Questions: 1Answers: 10,473 Site admin
    Don't bother - just let the discussion naturally sink down :-).
This discussion has been closed.