How to prevent initial ajax request on non serverSide?
How to prevent initial ajax request on non serverSide?
Hi there,
I want to start with a page load of an empty datatable then ajax a data request after a user action (fill in search conditions, validate input, etc).
Right now I have it setup so it ajax calls a dummy file at page load, then after user input I change the ajax URL using: table.ajax.url('NEWFILEPATH').load();
But is there a way to create the datatable object BUT prevent that dummy initial ajax request for data when NOT using serverSide processing? i.e. a deferLoading for clientSide?
Answers
Hi,
I've been having the same issue. I solved this by simply initializing the dataTable at the moment of the user action.
So basically instead of initializing your dataTable at e.g. (document).ready you could do it after a user submits his request (in your case the search conditions etc.)
Something like so
Hope it helps.
Paul
The other option is to make your own Ajax call and then use
rows.add()
to add the rows - i.e. bypass DataTables' own ajax options.Allan