how to use ajax.url(''url").load() for post params
how to use ajax.url(''url").load() for post params
D
Posts: 9Questions: 1Answers: 0
I am trying to use ajax.url('myurl').load() with post params.Since 'myurl' is a string I works well for get request.How can I apply the same to post?
Here is my datatable:
$('#example').dataTable( {
"ajax": { "url": "url", "type": "POST", "data":data } } ); } );
Everytime I reload the table ,i need to pass new data to the backend.
How can I achieve it by using ajax.url('myurl').load()?
Could anyone please point me with example.
This discussion has been closed.
Answers
I am using my datatable like below:
$('#example').dataTable( {
"ajax": {
"url": "data.json",
"contentType": "application/json",
"data": function ( d ) {
return JSON.stringify( d );
}
}
} );
I am in need to reload the table.I tried using ajax.url('myurl').load() where I have to pass new JSON data everytime.Is this possible to do?
http://datatables.net/reference/api/ajax.reload%28%29
Third example may help you.
Hi ThankYou!
The suggested example gives me the option -"Function which is executed when the data as been reloaded and the table fully redrawn."
I am trying to pass the json data to server and on every reload json will be different.
Is this possible?Can anyone help please?
write a method to get your data to post
data: getMyFormValuesJSONstringified,...
..and onSubmit tableInstance.ajax.reload(); should do the job as long as you don´t need different url...