Niner
Niner

Reputation: 2205

How to load data from ajax on button press?

I'm trying to load search results into DataTables control. So after the user inputs some parameter and pressing the 'Search' button, then I would like to see the data loaded in the DataTables control. How do I initiate DataTables to load data through ajax only upon a user triggered event? All the examples I have seen all load data immediately. Thanks.

Upvotes: 0

Views: 977

Answers (1)

markpsmith
markpsmith

Reputation: 4918

Use iDeferLoading in the initialisation code to prevent the datatable making a request on the initial page render.

'iDeferLoading': 1

Use fnDraw in your button click event to make the request with the user input as a parameter (see fnServerParams for this)

oTable.fnDraw();

Upvotes: 2

Related Questions