JQuery dataTable reload from new ajax source

I am using jQuery Datatable plugin. The initialization code is below

$('#Table').dataTable( { "sAjaxSource": url ... ... }); 

which is launched by pressing a button. Now when I click this button, I want to get dataTable with a different url. I tried using without success. Please suggest.

 if (typeof obj == 'undefined') { obj = $('#Table').dataTable( { "sAjaxSource": url ... ... }) }else { obj.fnClearTable(0); obj.fnDraw(false); } 
+8
jquery datatables
source share
3 answers

I think you need fnReloadAjax () . You should use it as follows:

 var oTable = $('#Table').dataTable( { "sAjaxSource": url ... ... }); var newUrl = "new.php"; oTable.fnReloadAjax(newUrl); 
+9
source share

Try 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 the table is not a dataTable:

$ ('# TABLEID') DataTable () ajax.url ("NEWURL") load (); ...

+3
source share

This worked for version 1.10:

  oTable.ajax.url("new_source_file.php"); oTable.draw(); 
0
source share

All Articles