Get HTTP Variables in server

Get HTTP Variables in server

NeochangeNeochange Posts: 4Questions: 0Answers: 0
edited June 2011 in General
Hello, I have a page that define a table and I call the datatable initilization on this way:

[code]
$(document).ready(
function() {
$('#table1').dataTable( {
"bProcessing": true,
"bServerSide": true,
'sAjaxSource':'get_data.php',
} );
} );
[/code]

I want to send some parameters to set my sql call and I don't know how can I make this. I have readed about overloading the .getJSON function and I tried this:

[code]
aoData.push( { "key1": "data1", "key2": "data2" } );
$.getJSON( sSource, aoData, function (json) {
fnCallback(json)
} );
[/code]

I don't know how I can get any parameters in the server page to use them.

Thank you

Replies

  • allanallan Posts: 63,161Questions: 1Answers: 10,406 Site admin
    There is an example of how to do it here: http://datatables.net/release-datatables/examples/server_side/custom_vars.html

    Allan
  • NeochangeNeochange Posts: 4Questions: 0Answers: 0
    Trank you, but that is the example I followed. My question is how I can get this variables when my get_Data.php is executed.
  • allanallan Posts: 63,161Questions: 1Answers: 10,406 Site admin
    edited June 2011
    If you use:

    [code]aoData.push( { "name": "more_data", "value": "my_value" } );[/code]

    Like in the example you just need:

    [code]
    $_GET['more_data']
    [/code]

    Note that there is a slight difference to how you have you key/value pair to the name/value pair in the example.

    Allan
  • NeochangeNeochange Posts: 4Questions: 0Answers: 0
    I solved it. I was trying to get variables through $_GET but I was using wrong parameters. Thank you again.
  • NeochangeNeochange Posts: 4Questions: 0Answers: 0
    I reply and I haven't seen your comment after, thanks a lot. Datatables plugin is awesome. :D
This discussion has been closed.