Server-side processing - add extra http variables: how to get?
Server-side processing - add extra http variables: how to get?
Hi!
I'm new to php but I use your example code from your "DataTables server-side processing example".
There is another code example on how to add more (custom) http variables.
But, how do I get them in the server side script? I tried to get them by calling $_GET['test'], using the following code:
[code]
$(document).ready(function() {
$('#keywords').dataTable( {
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "bin/keyword_list.php",
"fnServerData": function ( sSource, aoData, fnCallback ) {
/* Add some extra data to the sender */
aoData.push( { "test": "keks" } );
$.getJSON( sSource, aoData, function (json) {
/* Do whatever additional processing you want on the callback, then tell DataTables */
fnCallback(json)
} );
}
} );
} );
[/code]
But the key test does not seem to be set.
Where is my error?
best regards, Alex
I'm new to php but I use your example code from your "DataTables server-side processing example".
There is another code example on how to add more (custom) http variables.
But, how do I get them in the server side script? I tried to get them by calling $_GET['test'], using the following code:
[code]
$(document).ready(function() {
$('#keywords').dataTable( {
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "bin/keyword_list.php",
"fnServerData": function ( sSource, aoData, fnCallback ) {
/* Add some extra data to the sender */
aoData.push( { "test": "keks" } );
$.getJSON( sSource, aoData, function (json) {
/* Do whatever additional processing you want on the callback, then tell DataTables */
fnCallback(json)
} );
}
} );
} );
[/code]
But the key test does not seem to be set.
Where is my error?
best regards, Alex
This discussion has been closed.
Replies
I think you are just having a little issue with the slightly weird naming that jQuery needs for objects in the data parameter.
[code]
aoData.push( { "test": "keks" } );
[/code]
should actually be
[code]
aoData.push( { "name": "test", "value": "keks" } );
[/code]
See the example here: http://datatables.net/examples/server_side/custom_vars.html
Regards,
Allan