Trying to use fnReloadAjax to automatically refresh the table
Trying to use fnReloadAjax to automatically refresh the table
[code]
var oTable;
$(document).ready(function() {
oTable = $('#alarms').dataTable({
"bPaginate": false,
"bProcessing": true,
"sAjaxSource": '/alarms',
"bStateSave": true,
"aoColumns" : [
{ "mDataProp": "level" },
{ "mDataProp": "robot" },
{ "mDataProp": "message" },
{ "mDataProp": "source" },
{ "mDataProp": "pool" },
{ "mDataProp": "arrival" },
{ "mDataProp": "hub" },
{ "mDataProp": "nimid" },
{ "mDataProp": "subsys" },
]
});
setInterval(function()
{
oTable.fnReloadAjax();
},30000);
} );
[/code]
Here is what my javascript looks like but I get "Uncaught TypeError: Object [object Object] has no method 'fnReloadAjax'" like oTable isn't the dataTable object when the refresh interval comes up. Can someone please help me understand where my mistake is?
var oTable;
$(document).ready(function() {
oTable = $('#alarms').dataTable({
"bPaginate": false,
"bProcessing": true,
"sAjaxSource": '/alarms',
"bStateSave": true,
"aoColumns" : [
{ "mDataProp": "level" },
{ "mDataProp": "robot" },
{ "mDataProp": "message" },
{ "mDataProp": "source" },
{ "mDataProp": "pool" },
{ "mDataProp": "arrival" },
{ "mDataProp": "hub" },
{ "mDataProp": "nimid" },
{ "mDataProp": "subsys" },
]
});
setInterval(function()
{
oTable.fnReloadAjax();
},30000);
} );
[/code]
Here is what my javascript looks like but I get "Uncaught TypeError: Object [object Object] has no method 'fnReloadAjax'" like oTable isn't the dataTable object when the refresh interval comes up. Can someone please help me understand where my mistake is?
This discussion has been closed.
Replies
http://www.datatables.net/plug-ins/api#fnReloadAjax
[code]
$.fn.dataTableExt.oApi.fnReloadAjax = function ( oSettings, sNewSource, fnCallback, bStandingRedraw )
{
if ( typeof sNewSource != 'undefined' && sNewSource != null )
{
oSettings.sAjaxSource = sNewSource;
}
this.oApi._fnProcessingDisplay( oSettings, true );
var that = this;
var iStart = oSettings._iDisplayStart;
oSettings.fnServerData( oSettings.sAjaxSource, [], function(json) {
/* Clear the old information from the table */
that.oApi._fnClearTable( oSettings );
/* Got the data - add it to the table */
for ( var i=0 ; i
Allan