[英]jQuery table refresh but duplication occurs
我想每秒刷新一次數據表的內容。 下面的代碼可以工作,但是它復制了其他對象,如下圖所示。
它的代碼tableHolder
是表ID。
<script type="text/javascript">
$(document).ready(function(){
$('#{tableHolder}').DataTable();
});
$(document).ready(function(){
refreshTable();
});
function refreshTable(){
$('#tableHolder').load('.dataTakenFromTheUrl’, function(){
setTimeout(refreshTable, 1000);
});
}
</script>
我也嘗試了以下方法,但是不起作用。 我收到DataTables warning: table id=tableHolder - Invalid JSON response. For more information about this error, please see datatables.net/tn/1
DataTables warning: table id=tableHolder - Invalid JSON response. For more information about this error, please see datatables.net/tn/1
var table = $('#tableHolder').DataTable();
table.ajax.reload();
我需要第一個示例中的內容。 如果刪除以下部分,則顯示10個條目,搜索欄,訂購箭頭消失。
$(document).ready(function(){
$('#{tableHolder}').DataTable();
});
首先,檢查數據表的版本。
如果數據表版本舊,則使用:
var table = $('#tableHolder').DataTable();
table.api().ajax.reload();
如果版本是New,則使用:
var table = $('#tableHolder').DataTable();
table.ajax.reload();
希望使用以上腳本可以解決您的問題。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.