6

I want to load data into a jquery datatable with ajax. Also I want to send parameters to the function that pulls the data from the database.

So what I want to do:

$('#datatables').dataTable( {
    "bProcessing": true,
    "bServerSide": true,
    "sAjaxSource": "/results/load-results",
    "fnServerParams": function ( aoData ) {
        aoData.push( { "quizid": quizid, "questionid": qid } );
    }
} );

I want to so send the quizid and questionid and use them in my function. How can I pull them in my function? Tried $_GET but didn't work ..

3
  • 1
    Have you read this? datatables.net/forums/discussion/6600/… (TLDR: are you running version 1.8.2?) Commented Sep 25, 2013 at 8:01
  • Ok, but my questions is: how can I get these variables in my php function? Commented Sep 25, 2013 at 8:14
  • Have you tried dumping GET and/or POST vars in your php script (load_results) to see what values you have? Commented Sep 25, 2013 at 8:20

1 Answer 1

15

Format must be

"fnServerParams": function ( aoData ) {
      aoData.push( { "name": "quizid", "value": quizid },{ "name": "questionid", "value": qid } );
},
Sign up to request clarification or add additional context in comments.

1 Comment

well how about if datatable has filtering multiple columns send variable by onclick, thanks

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.