ajax reload,ajax.reload()

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:NameTypeOptional1callbackYes - default:null

Function which is executed when the data has been reloaded and the table fully redrawn. The function is given a single parameter - the JSON data returned by the server, and expects no return.

2resetPagingYes - default:true

Reset (default action or true) or hold the current paging position (false). A full re-sort and re-filter is performed when this method is called, which is why the pagination reset is the default action.Returns:DataTables.Api instance

Examples

Reload the table data every 30 seconds (paging reset):var table = $('#example').DataTable( {

ajax: "data.json"

} );

setInterval( function () {

table.ajax.reload();

}, 30000 );

Reload the table data every 30 seconds (paging retained):var table = $('#example').DataTable( {

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 = $('#example').DataTable();

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.

Events

Options

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值