[英]datatable.ajax.reload() with setInterval causes page crash, how can i avoid memory leak?
Here's my code, Ajax request for dataTable return 2000 rows of data.这是我的代码,Ajax 请求 dataTable 返回 2000 行数据。 I want to update datatable every 2 seconds with new data.我想每 2 秒用新数据更新一次数据表。 It is requesting 2000 rows of data every 2 seconds.它每 2 秒请求 2000 行数据。 But with setInterval the page crashes after 10-12 minutes because of memory error.但是使用 setInterval 时,由于 memory 错误,页面会在 10-12 分钟后崩溃。 Is there any way to clear the memory without using location.reload()有没有办法在不使用location.reload()的情况下清除 memory
var dataTable = $('#tblDemo').DataTable({
"ajax": {
"serverSide": true,
url: "abc.php?data=getSomeData",
type: "POST",
data: {}
},
"pageLength": 15
});
setInterval(function() {
dataTable.ajax.reload(null, false);
}, 2000);
use "destroy"
option to destroy old data.使用"destroy"
选项销毁旧数据。
Reference:: https://datatables.net/reference/api/destroy()参考:: https://datatables.net/reference/api/destroy()
https://datatables.net/reference/option/destroy https://datatables.net/reference/option/destroy
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.