$.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 */
var aData = (oSettings.sAjaxDataProp !== "") ?
that.oApi._fnGetObjectDataFn( oSettings.sAjaxDataProp )( json ) : json;
for ( var i=0 ; i<aData.length ; i++ )
{
that.oApi._fnAddData( oSettings, aData[i] );
}
oSettings.aiDisplay = oSettings.aiDisplayMaster.slice();
that.fnDraw();
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 );
}
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
var oTable = $('#example').dataTable( {
"bProcessing": true,
"bDeferRender": true,
"sAjaxSource": "sources/arrays.txt"
} );
} );
</script>
oTable.fnReloadAjax( 'sources/arrays2.txt' );
<script type="text/javascript" charset="utf-8">
var oTable;
$(document).ready(function() {
oTable = $('#example').dataTable( {
"bProcessing": true,
"bDeferRender": true,
"sAjaxSource": "sources/arrays.txt"
} );
} );
</script>
$('#example').dataTable().fnReloadAjax();
oTable.fnReloadAjax( 'sources/' + chosen + '.txt' )
<script type="text/javascript" charset="utf-8">
function GetSelectedItem() {
len = document.f1.s1.length;
i = 0;
chosen = "none";
for (i = 0; i < len; i++) {
if (document.f1.s1[i].selected) {
chosen = document.f1.s1[i].value;
}
}
alert(chosen);
oTable.fnReloadAjax( 'sources/' + chosen + '.txt' );
}
</script>
<form name="f1"> <select name="s1" onChange = GetSelectedItem()> <option value="none">Please select</option> <option value="arrays">Arrays</option> <option value="arrays2">Arrays2</option> </select> </form>
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.