Server-side processing - add extra http variables: how to get?

Server-side processing - add extra http variables: how to get?

nm_alexnm_alex Posts: 26Questions: 0Answers: 0
edited November 2009 in General
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

Replies

  • allanallan Posts: 61,822Questions: 1Answers: 10,127 Site admin
    Hi Alex,

    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
  • nm_alexnm_alex Posts: 26Questions: 0Answers: 0
    Ah yes, that was the fault. Now it works fine. Thanks!
This discussion has been closed.