Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Send parameters with ajax call from jquery datatables

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 ..

like image 652
nielsv Avatar asked Sep 25 '13 07:09

nielsv


1 Answers

Format must be

"fnServerParams": function ( aoData ) {
      aoData.push( { "name": "quizid", "value": quizid },{ "name": "questionid", "value": qid } );
},
like image 134
Se0ng11 Avatar answered Nov 14 '22 22:11

Se0ng11