<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
var oTable;
oTable = $('#example').dataTable( {
"bJQueryUI": true,
"sPaginationType": "full_numbers",
"bProcessing": false,
"sAjaxSource": 'config/incoming_calls_array.txt'
} );
setInterval(function() { oTable.fnDraw; }, 5000);
} );
</script>
<div id="dynamic"> <table cellpadding="0" cellspacing="0" border="0" class="display" id="example"> <thead> <tr> <th width="25%">Caller</th> <th width="25%">City</th> <th width="25%">Province</th> <th width="25%">Phone</th> </tr> </thead> <tbody> </tbody> <tfoot> </tfoot> </table> </div>
setInterval(function() { oTable.fnDraw(); }, 5000);
setInterval(oTable.fnDraw, 5000);)
setInterval('$("#myTable").dataTable().fnDraw()', 5000);
setInterval('oTable.fnDraw()', 5000);
<?php
header("Cache-Control: no-cache");
header("Expires: -1");
?>
{ "aaData": [
["Trident","Internet Explorer 4.0","Win 95+","4","X"],
["Trident","Internet Explorer 5.0","Win 95+","5","C"],
["Trident","Internet Explorer 5.5","Win 95+","5.5","A"],
["Trident","Internet Explorer 6","Win 98+","6","A"],
["Trident","Internet Explorer 7","Win XP SP2+","7","A"],
["Trident","AOL browser (AOL desktop)","Win XP","6","A"],
// ... etc
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>PhoneDJ</title>
<style type="text/css" title="currentStyle">
@import "css/demo_page.css";
@import "css/demo_table_jui.css";
@import "css/custom-theme/jquery-ui-1.8.14.custom.css";
</style>
<script type="text/javascript" src="js/jquery-1.5.1.min.js"></script>
<script type="text/javascript" language="javascript" src="js/jquery.dataTables.js"></script>
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
var oTable = $("#example").dataTable( {
"bJQueryUI": true,
"sPaginationType": "full_numbers",
"sAjaxSource": 'config/incoming_calls_array.php'
} );
var refresh = setInterval('$("#example").dataTable().fnDraw()', 5000);
} );
</script>
</head>
<body>
<table cellpadding="0" cellspacing="0" border="0" class="display" id="example">
<thead>
<tr>
<th width="25%">Caller</th>
<th width="25%">City</th>
<th width="25%">Province</th>
<th width="25%">Phone</th>
</tr>
</thead>
<tbody>
</tbody>
<tfoot>
</tfoot>
</table>
</body>
</html>
<?php
header("Cache-Control: no-cache");
header("Expires: -1");
?>
{ "aaData": [
["Trident","Internet Explorer 4.0","Win 95+","4","X"],
["Trident","Internet Explorer 5.0","Win 95+","5","C"],
["Trident","Internet Explorer 5.5","Win 95+","5.5","A"],
["Trident","Internet Explorer 6","Win 98+","6","A"],
["Trident","Internet Explorer 7","Win XP SP2+","7","A"],
["Trident","AOL browser (AOL desktop)","Win XP","6","A"],
["Gecko","Firefox 1.0","Win 98+ / OSX.2+","1.7","A"],
["Gecko","Firefox 1.5","Win 98+ / OSX.2+","1.8","A"],
["Gecko","Firefox 2.0","Win 98+ / OSX.2+","1.8","A"],
["Gecko","Firefox 3.0","Win 2k+ / OSX.3+","1.9","A"],
["Gecko","Camino 1.0","OSX.2+","1.8","A"],
["Gecko","Camino 1.5","OSX.3+","1.8","A"],
["Gecko","Netscape 7.2","Win 95+ / Mac OS 8.6-9.2","1.7","A"],
["Gecko","Netscape Browser 8","Win 98SE+","1.7","A"],
["Gecko","Netscape Navigator 9","Win 98+ / OSX.2+","1.8","A"],
["Gecko","Mozilla 1.0","Win 95+ / OSX.1+",1,"A"],
["Gecko","Mozilla 1.1","Win 95+ / OSX.1+",1.1,"A"],
["Gecko","Mozilla 1.2","Win 95+ / OSX.1+",1.2,"A"],
["Gecko","Mozilla 1.3","Win 95+ / OSX.1+",1.3,"A"],
["Gecko","Mozilla 1.4","Win 95+ / OSX.1+",1.4,"A"],
["Misc","PSP browser","PSP","-","C"],
["OtherS browsers","All others","-","-","U"]
] }
...
var oTable = $("#example").dataTable( {
"bJQueryUI": true,
"sPaginationType": "full_numbers",
"sAjaxSource": 'config/incoming_calls_array.php',
"fnServerData": function ( sSource, aoData, fnCallback ) {
$.ajax( {
dataType: 'json',
type: "GET",
cache: false,
url: sSource,
data: aoData,
success: fnCallback
} )
}
} );
...
$.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<json.aaData.length ; i++ )
{
that.oApi._fnAddData( oSettings, json.aaData[i] );
}
oSettings.aiDisplay = oSettings.aiDisplayMaster.slice();
that.fnDraw( that );
if ( typeof bStandingRedraw != 'undefined' && bStandingRedraw === true )
{
oSettings._iDisplayStart = iStart;
that.fnDraw( false );
}
that.oApi._fnProcessingDisplay( oSettings, false );
/* Callback user function - for event handlers etc */
if ( typeof fnCallback == 'function' && fnCallback != null )
{
fnCallback( oSettings );
}
}, oSettings );
}
setInterval(oTable.fnReloadAjax, 5000); /* Example call to load a new file */ oTable.fnReloadAjax( 'media/examples_support/json_source2.txt' ); /* Example call to reload from original file */ oTable.fnReloadAjax();
var oTable = $('#example').dataTable( { ... } );
setInterval( function () {
oTable.fnReloadAjax();
}, 5000 );
var oTable;
oTable = $('#example').dataTable( {
"sPaginationType": "full_numbers",
"bJQueryUI": true,
"sAjaxSource": 'config/incoming_calls_array.txt',
"fnServerData": function ( sSource, aoData, fnCallback ) {
/* Add some data to send to the source, and send as 'POST' */
$.ajax( {
"dataType": 'json',
"type": "POST",
"url": sSource,
"cache": false,
"data": aoData,
"success": fnCallback
} );
}
} );
var newtimer = setInterval( function () {
oTable.fnReloadAjax();
}, 3000 );
} );
tjyoung said: can you tell me how to incorporate nStandingRedraw(); into it?
/* install an extension API function */
$.fn.dataTableExt.oApi.fnStandingRedraw = function(oSettings) {
//redraw to account for filtering and sorting
// concept here is that (for client side) there is a row got inserted at the end (for an add)
// or when a record was modified it could be in the middle of the table
// that is probably not supposed to be there - due to filtering / sorting
// so we need to re process filtering and sorting
// BUT - if it is server side - then this should be handled by the server - so skip this step
if(oSettings.oFeatures.bServerSide === false){
var before = oSettings._iDisplayStart;
oSettings.oApi._fnReDraw(oSettings);
//iDisplayStart has been reset to zero - so lets change it back
oSettings._iDisplayStart = before;
oSettings.oApi._fnCalculateEnd(oSettings);
}
//draw the 'current' page
oSettings.oApi._fnDraw(oSettings);
};
$(document).ready( function () {
var oTable;
oTable = $('#example').dataTable( {
"sPaginationType": "full_numbers",
"bJQueryUI": true,
"sAjaxSource": 'config/incoming_calls_array.txt',
"fnServerData": function ( sSource, aoData, fnCallback ) {
/* Add some data to send to the source, and send as 'POST' */
$.ajax( {
"dataType": 'json',
"type": "POST",
"url": sSource,
"cache": false, // HOORAY for cache = false!!
"data": aoData,
"success": fnCallback
} );
}
} );
var newtimer = setInterval( function () {
oTable.fnStandingRedraw();
}, 3000 );
} );
$.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<json.aaData.length ; i++ )
{
that.oApi._fnAddData( oSettings, json.aaData[i] );
}
oSettings.aiDisplay = oSettings.aiDisplayMaster.slice();
that.fnDraw( that );
if ( typeof bStandingRedraw != 'undefined' && bStandingRedraw === true )
{
oSettings._iDisplayStart = iStart;
that.fnDraw( false );
}
that.oApi._fnProcessingDisplay( oSettings, false );
/* Callback user function - for event handlers etc */
if ( typeof fnCallback == 'function' && fnCallback != null )
{
fnCallback( oSettings );
}
}, oSettings );
}
$(document).ready( function () {
var oTable;
oTable = $('#example').dataTable( {
"sPaginationType": "full_numbers",
"bJQueryUI": true,
"sAjaxSource": 'config/incoming_calls_array.txt',
"fnServerData": function ( sSource, aoData, fnCallback ) {
/* Add some data to send to the source, and send as 'POST' */
$.ajax( {
"dataType": 'json',
"type": "POST",
"url": sSource,
"cache": false, // HOORAY for cache = false!!
"data": aoData,
"success": fnCallback
} );
}
} );
var newtimer = setInterval( function () {
oTable.fnReloadAjax();
}, 3000 );
} );
if ( typeof bStandingRedraw == 'undefined' && bStandingRedraw != true )
It looks like you're new here. If you want to get involved, click one of these buttons!
Get useful and friendly help straight from the source.