Why does -1 as draw causes infinite loading?

Why does -1 as draw causes infinite loading?

luisluixluisluix Posts: 6Questions: 2Answers: 0

I been messing around with the parameters in data tables, usually if I change the draw value to any number it works, but with -1 the ajax request returns and the datatable is stuck in a forever loading state.

Replies

  • kthorngrenkthorngren Posts: 20,275Questions: 26Answers: 4,765

    Are you talking about the draw parameter for server side processing?

    Maybe you can describe more about what your are doing and what you are trying to accomplish.

    Kevin

  • allanallan Posts: 61,664Questions: 1Answers: 10,095 Site admin

    If you are using -1 length with server-side processing, don't. It just means you'd be loading all the data for the table on every draw, rather than requesting it just once.

    To my mind, server-side processing only makes sense when paging is enabled.

    Allan

  • luisluixluisluix Posts: 6Questions: 2Answers: 0

    yes im talking about the draw parameter and yes im doing server side processing.
    im testing the application for possible error pages. But it just seems weird that datatables doesnt know that we received an out of order request that we didnt ask for, it gets ignored (like it should) but datatables is now forever waiting for the actual request which we are never going to get... shouldnt datatables show an error in this scenario?

    im messing around with a web debugger and changing the values of things. It just feels off that datatables isnt aware that all the ajax calls have been completed and we are never going to get the data.

    sorry if this feels very out of topic, just thought this was a strange scenario.

  • allanallan Posts: 61,664Questions: 1Answers: 10,095 Site admin

    Sorry! I thought we were talking about the page length.

    -1 would indeed be invalid for draw since DataTables never sends that. Odd that it would cause an infinite loop though - I'd expect it just to stall.

    The draw parameter shouldn't really be needed - as you suggestion, DataTables should really keep track of the requests and discard out of sequence requests itself without the draw parameter. It was a fix from "back in the day" and its going to be removed for v2. Until then, you need to just return the integer (make sure you parse it as an int for security) to the client-side from the request parameters.

    Allan

This discussion has been closed.