How to pass new POST parameters on Ajax.reload?
How to pass new POST parameters on Ajax.reload?
venlentine
Posts: 2Questions: 1Answers: 0
I want to be able to reload my datatable with AJAX, but need to be able to pass POST parameters.
Here is how I initialize the table
$('#list').DataTable( {
"ajax": {
"url": '${ctx}/work/list_ajax.json',
"type": 'POST'
},
Here is how I reload the AJAX source:
$('#list').DataTable().ajax.reload(null, false).draw();
How can I pass new/updated parameters into the ajax.reload call?
This question has accepted answers - jump to:
This discussion has been closed.
Answers
I find solution!
Custom function to ajax.data
eg:
Yup - bob on :-). Thanks for posting your solution.
Allan
But with this solution... the default parameters, draw, search etc... are not sent...
I search another solution...
As long as you have
serverSide
enabled, then yes they should be. If they are not, please link to a test case showing the problem.Allan
I can confirm the issue. im using v1.9.3
using this code
when reloading, the "to" and "from" stays the same, even if I change the UI input, so the workaround from valentine works, but now the default params arent sent.
"data" with buildSearchData function
I was thinking of re-typing the defaults params in the function manually.
but how can i get them?
Ok so here is the work around, hope it helps someone
But not working, cant "refresh" the data....
i can do that setting a new ajaxurl (via get) but i cant via post..
var tableAjax = $('#table_vendas').DataTable();
tableAjax.ajax.url('vendas_filter.php?'+$('#formFilter').serialize()).load();
Ok.
I solved that way:
"ajax": {
"url": 'filter.php',
"type": 'POST',
"data": function ( d ) {
return $('#formFilter').serialize();
}
},