server side JSON not paging

server side JSON not paging

confundidoconfundido Posts: 15Questions: 5Answers: 0

Here's the HTML page: https://www.freecell.net/f/c/dbscores1.html?flavor=day&game=8x4

Here's the JSON source under the covers: http://freecell.net/f/fcv.p?start=0&length=100&game=8x4

It shows the proper number of pages but selecting page 2 never re-draws. I see the AJAX call to my server side Perl thingy but the UI never updates.

Datatables debugger didn't show anything. Nothing in the console.

More tomorrow.

confundido

Answers

  • colincolin Posts: 15,112Questions: 1Answers: 2,583
    edited September 2019

    Hi @confundido ,

    The problem is because draw isn't being incremented - it's always returning 1. If it's the same as the client has received before, it's ignored.

    Cheers,

    Colin

  • confundidoconfundido Posts: 15Questions: 5Answers: 0

    Ah ha, that works. Went back and re-read the docs about draw. No hint (that I see) that it needed to be incremented. It sounded like a unique req Id that I'd just echo back. But yeah, I never saw it passed as anything but 1.

    Docs currently:
    ...it is strongly recommended for security reasons that you cast this parameter to an integer, rather than simply _**echoing **_back to the client what it sent in the draw parameter...

    "Echoing" threw me off. Might want to add to the docs that this field needs to be incremented and huge thanks for the help.

    confundido

  • confundidoconfundido Posts: 15Questions: 5Answers: 0

    Hmmm... researching another issue found a posting recommending:

    "Your server response needs the match the sequence number sent."

    That's from here: https://datatables.net/forums/discussion/57628

  • kthorngrenkthorngren Posts: 20,141Questions: 26Answers: 4,735

    The draw value in the response isn't intended to be incremented. It is intend to be the value of the draw from the request. It is used as a sequence number. This way if Datatables sends two requests, draw = 1 then draw = 2 and the response is draw = 1 then it knows the data is from a previous request and to not process it.

    HTH, to explain that parameter.

    Kevin

  • confundidoconfundido Posts: 15Questions: 5Answers: 0

    That was my impression exactly from the docs but Colin above says to increment and that mysteriously makes things work.

    confundido

  • kthorngrenkthorngren Posts: 20,141Questions: 26Answers: 4,735

    He probably meant it in a more generic sense indicating that your draw response was always the same. Simply incrementing won't guarantee the sequence will always work. Take for example this set of steps:

    • Load the page, Datatables requests the first set of data and expects draw = 1
    • Got to the next page Datatables expects draw = 2 and your script increments the counter and responds with 2
    • The person reloads the page, Datatables requests the first set of data with draw = 1 however your script increments and responds with draw = 3. Datatables will ignore the data.

    Kevin

  • colincolin Posts: 15,112Questions: 1Answers: 2,583

    That was my impression exactly from the docs but Colin above says to increment and that mysteriously makes things work.

    Ignore me, I'm daft! Kevin's explanation is correct, it needs to match the request. In m mind, that's always incrementing, but that's just a partial answer (fully explained by Kevin's response).

  • confundidoconfundido Posts: 15Questions: 5Answers: 0

    Ah ha again. I think the issue was I wasn't properly fetching the draw param Now it's working without the increment thing.

This discussion has been closed.