passing variable to aoData.push
passing variable to aoData.push
datatables_help
Posts: 3Questions: 0Answers: 0
Hi,
I am passing on variables (something like - filename.php?val=1&val2=2) from server side processing(datatables1.html/data.php) to another datatables html file(datatables2.html).
Since I am passing on variables I have saved second datatables file as datatables2.php .
I am getting variables in datatables2.php as:
[code]
<?php
$var1 = $_GET['val'];
$var2= $_GET['val2'];
?>
[/code]
Now I want to use these variables in datatables functions in datatables2.php file . Here is the javascript snippet :
[code]
$(document).ready(function() {
$("#tabs").tabs( {
"show": function(event, ui) {
var jqTable = $('table.display', ui.panel);
if ( jqTable.length > 0 ) {
var oTableTools = TableTools.fnGetInstance( jqTable[0] );
if ( oTableTools != null && oTableTools.fnResizeRequired() )
{
jqTable.dataTable().fnAdjustColumnSizing();
oTableTools.fnResizeButtons();
}
}
}
} );
$('#example').dataTable( {
"bJQueryUI": true,
"bProcessing": true,
"bServerSide": true,
<!-- determine # of records to display -->
"iDisplayLength": 50,
<!-- save the state which user has set -->
"bStateSave": true,
"sPaginationType": "full_numbers",
"sAjaxSource": "scripts/listlocation.php",
"fnServerParams": function ( aoData ) {
aoData.push( { "name": "abc", "value": "<?php echo $var1 ?>" });
aoData.push( { "name": "xyz", "value": "<?php echo $var2 ?>"});
}
});
});
[/code]
As you can see with aoData.push I want to achieve something like - scripts/listlocation.php?abc=(value_of_$var1)&xyz=(value_of_$var2)
For example - scripts/listlocation.php?abc=123&xyz=location
How can I pass variables to aoData.push ?
Thanks in advance!
I am passing on variables (something like - filename.php?val=1&val2=2) from server side processing(datatables1.html/data.php) to another datatables html file(datatables2.html).
Since I am passing on variables I have saved second datatables file as datatables2.php .
I am getting variables in datatables2.php as:
[code]
<?php
$var1 = $_GET['val'];
$var2= $_GET['val2'];
?>
[/code]
Now I want to use these variables in datatables functions in datatables2.php file . Here is the javascript snippet :
[code]
$(document).ready(function() {
$("#tabs").tabs( {
"show": function(event, ui) {
var jqTable = $('table.display', ui.panel);
if ( jqTable.length > 0 ) {
var oTableTools = TableTools.fnGetInstance( jqTable[0] );
if ( oTableTools != null && oTableTools.fnResizeRequired() )
{
jqTable.dataTable().fnAdjustColumnSizing();
oTableTools.fnResizeButtons();
}
}
}
} );
$('#example').dataTable( {
"bJQueryUI": true,
"bProcessing": true,
"bServerSide": true,
<!-- determine # of records to display -->
"iDisplayLength": 50,
<!-- save the state which user has set -->
"bStateSave": true,
"sPaginationType": "full_numbers",
"sAjaxSource": "scripts/listlocation.php",
"fnServerParams": function ( aoData ) {
aoData.push( { "name": "abc", "value": "<?php echo $var1 ?>" });
aoData.push( { "name": "xyz", "value": "<?php echo $var2 ?>"});
}
});
});
[/code]
As you can see with aoData.push I want to achieve something like - scripts/listlocation.php?abc=(value_of_$var1)&xyz=(value_of_$var2)
For example - scripts/listlocation.php?abc=123&xyz=location
How can I pass variables to aoData.push ?
Thanks in advance!
This discussion has been closed.
Replies
Allan
Great tool by the way : -)