passing variable to aoData.push

passing variable to aoData.push

datatables_helpdatatables_help Posts: 3Questions: 0Answers: 0
edited April 2013 in General
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!

Replies

  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin
    Looks like it should work to me. Can you link to a test case please: http://datatables.net/forums/discussion/12899/post-test-cases-when-asking-for-help-please-read ?

    Allan
  • datatables_helpdatatables_help Posts: 3Questions: 0Answers: 0
    Sorry Allan not sure what I was doing . It is working with above code , probably I had not refreshed browser or something . Sorry for the false alarm!
    Great tool by the way : -)
This discussion has been closed.