Error fnDraw() is not defined
Error fnDraw() is not defined
Hi all,
I want to refresh data in the table every 30 sec, I was reading on this forum a lot. And I saw that for the server side processing I can call fnDraw() function every 30 sec and it will populate all new entries that are made to the table?
Here is my code:
[code]
$(document).ready(function() {
$('#jphit').dataTable( {
"bProcessing": true,
"bServerSide": true,
"sScrollY": "350px",
"bDeferRender": true,
"oTableTools": {
"aButtons": [
"copy",
"print",
{
"sExtends": "collection",
"sButtonText": "Save",
"aButtons": [ "csv", "xls", "pdf" ]
}
]
},
"sAjaxSource": "increment_table.php"
} );
setInterval('fnDraw()',30000);
[/code]
I am getting an error that fnDraw() is not defined.
I want to refresh data in the table every 30 sec, I was reading on this forum a lot. And I saw that for the server side processing I can call fnDraw() function every 30 sec and it will populate all new entries that are made to the table?
Here is my code:
[code]
$(document).ready(function() {
$('#jphit').dataTable( {
"bProcessing": true,
"bServerSide": true,
"sScrollY": "350px",
"bDeferRender": true,
"oTableTools": {
"aButtons": [
"copy",
"print",
{
"sExtends": "collection",
"sButtonText": "Save",
"aButtons": [ "csv", "xls", "pdf" ]
}
]
},
"sAjaxSource": "increment_table.php"
} );
setInterval('fnDraw()',30000);
[/code]
I am getting an error that fnDraw() is not defined.
This discussion has been closed.
Replies
Allan
[code]
$(document).ready(function() {
var oTable = $('#jphit').dataTable( {
"bProcessing": true,
"bServerSide": true,
"sScrollY": "350px",
"bDeferRender": true,
"oTableTools": {
"aButtons": [
"copy",
"print",
{
"sExtends": "collection",
"sButtonText": "Save",
"aButtons": [ "csv", "xls", "pdf" ]
}
]
},
"sAjaxSource": "increment_table.php"
} );
setInterval(oTable.fnDraw(),3000);
[/code]
You need to add an anonymous function into setInterval which will call oTable.fnDraw()
Allan