Usage of draw in datatables
Usage of draw in datatables
stackhello
Posts: 4Questions: 2Answers: 0
I am well aware the usage of draw in server side processing of datatables. However, i am not clear how the response of "draw" parameter in json works. Does it automatically ensure that the Ajax returns from server-side processing requests are drawn in sequence by DataTables if the "draw" value is included in the response json? Or any additional logic is required for it to be drawn in sequence?
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
The
draw
parameter (server-side processing) is just a sequence counter. It allows responses to come back out of order and DataTables will draw the correct page.For example:
This is done automatically by DataTables.
Allan
Thanks for your reply. May i know is there any built-in way to get the draw number of the request on ajax response? or just simply asssign draw = request.draw in ajax return json value?
You could use
xhr
orajax.json
to get the JSON data from the last request and thus access thedraw
parameter. Why would you need to get it after the data is fetched?At the server-side it should just be
draw = parseInt( input.draw );
(or however you access parameters on whatever server environment you are using). Make sure to cast it as an integer for security.Allan