I am using Datatables and have a button on the page that refreshes the table using AJAX. To be clear the table isn\'t using an ajax source of data, we are just using ajax to ref
This is how I feed my table with data retrieved by ajax (not sure if this is the best practice tough, but it feels intuitive and works well):
/* initialise table */
oTable1 = $( '.tables table' ).dataTable
( {
'sPaginationType': 'full_numbers',
'bLengthChange': false,
'aaData': [],
'aoColumns': [{"sTitle": "Tables"}],
'bAutoWidth': true
} );
/*retrieve data*/
function getArr( conf_csv_path )
{
$.ajax
({
url : 'my_url'
success : function( obj )
{
update_table( obj );
}
});
}
/* build table data */
function update_table( arr )
{
oTable1.fnClearTable();
for ( input in arr )
{
oTable1.fnAddData( [ arr[input] );
}
}