{hero}

ajax.reload()

Since: DataTables 1.10

Reload the table data from the Ajax data source.

Description

In an environment where the data shown in the table can be updated at the server-side, it is often useful to be able to reload the table, showing the latest data. This method provides exactly that ability, making an Ajax request to the already defined URL (use ajax.url() if you need to alter the URL).

Type

function ajax.reload( callback, resetPaging )

Parameters:
Returns:

DataTables.Api instance

Examples

Reload the table data every 30 seconds (paging reset):

var table = new DataTable('#myTable', {
	ajax: 'data.json'
});

setInterval(function () {
	table.ajax.reload();
}, 30000);

Reload the table data every 30 seconds (paging retained):

var table = new DataTable('#myTable', {
	ajax: 'data.json'
});

setInterval(function () {
	table.ajax.reload(null, false); // user paging is not reset on reload
}, 30000);

Use the callback to update an external elements:

var table = new DataTable('#myTable');

table.ajax.reload(function (json) {
	$('#myInput').val(json.lastInput);
});

Related

The following options are directly related and may also be useful in your application development.