Error Message ("Cannot reinitialise") when try to refresh in interval
Error Message ("Cannot reinitialise") when try to refresh in interval
susanadhikary
Posts: 3Questions: 1Answers: 0
i want to refresh my table in time intervals but every time i tired to do soo i got this message
any suggestions Please help
This discussion has been closed.
Answers
This tech note as details about that error.
Allan
i want to load table from database dynamically so i want to refresh it every millisecond
setInterval((function),10); but it gave me that error alert all time
var asInitVals = new Array();
$(document).ready(setInterval(function() {
var oTable = $('#example').dataTable({
"oLanguage": {
"sSearch": "Search all columns:"
},
"aoColumnDefs": [
{
'bSortable': false,
'aTargets': [0]
} //disables sorting for column one
],
'iDisplayLength': 12,
"sPaginationType": "full_numbers",
"dom": 'T<"clear">lfrtip',
"tableTools": {
"sSwfPath": "<?php echo base_url('assest/js/Datatables/tools/swf/copy_csv_xls_pdf.swf'); ?>"
}
});
$("tfoot input").keyup(function () {
/* Filter on the column based on the index of this element's parent <th> */
oTable.fnFilter(this.value, $("tfoot th").index($(this).parent()));
});
$("tfoot input").each(function (i) {
asInitVals[i] = this.value;
});
$("tfoot input").focus(function () {
if (this.className == "search_init") {
this.className = "";
this.value = "";
}
});
$("tfoot input").blur(function (i) {
if (this.value == "") {
this.className = "search_init";
this.value = asInitVals[$("tfoot input").index(this)];
}
});
},80));
Recreating a full DataTable every ten milliseconds is going to crush performance both on your server (an XHR request every ten milliseconds for every client connected?!) and on the client (that's a lot of DOM processing, even for a modern i7 machine).
Aside from that, did you read the tech note? I don't see any use of the
destroy
option as it suggests for such a case: direct link.Allan