What does data.draw and setTimeout do ?

What does data.draw and setTimeout do ?

chaturvedi_anshumaanchaturvedi_anshumaan Posts: 25Questions: 5Answers: 0

https://datatables.net/extensions/scroller/examples/initialisation/server-side_processing.html.
In this example we come across a setTimeout function. Could any one explain to me what is happening in that code?

setTimeout( function () {
callback( {
draw: data.draw,
data: out,
recordsTotal: 5000000,
recordsFiltered: 5000000
} );
}, 50 );

Answers

  • colincolin Posts: 15,237Questions: 1Answers: 2,599

    It's faking an ajax call. Because the function is just creating the data (in the lines above what you pasted), it then creates a small delay, and passes that back to DataTables to emulate a real Ajax call.

    Not useful practically, but good for demonstrating how Scroller can be used with limitless amounts of data.

    Colin

  • chaturvedi_anshumaanchaturvedi_anshumaan Posts: 25Questions: 5Answers: 0

    So, how would we be using or calling ajax with scroller in real world application ?

  • colincolin Posts: 15,237Questions: 1Answers: 2,599

    The same as you would here. There, it would just call your end-point to get the data.

    Colin

This discussion has been closed.