I am using jquery Datatable plugin. The init code is like below
$('#Table').dataTable( {
"sAjaxSource": url
...
...
});
which gets fired on click of a button.Now on click of that button again I want to get the dataTable with a different url. I have tried using without success.Please suggest.
if (typeof obj == 'undefined') {
obj = $('#Table').dataTable( {
"sAjaxSource": url
...
...
})
}else
{
obj.fnClearTable(0);
obj.fnDraw(false);
}
I think what you need is fnReloadAjax() . You should use it like this:
var oTable = $('#Table').dataTable( {
"sAjaxSource": url
...
...
});
var newUrl = "new.php";
oTable.fnReloadAjax(newUrl);
Try with this link: http://datatables.net/reference/api/ajax.url()
var table = $('#example').DataTable( { ajax: "data.json" } );
table.ajax.url( 'newData.json' ).load();
or as I did if table is not a dataTable object:
$('#tableId').DataTable().ajax.url("newUrl").load();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With