使用jquery datatables的ajax调用发送参数

时间:2022-12-08 20:01:52

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.

我想用ajax将数据加载到jquery数据表中。我还想向从数据库中提取数据的函数发送参数。

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

我想发送quizid和questionid并在我的函数中使用它们。如何在函数中提取它们?尝试了$_GET但没有成功。

1 个解决方案

#1


15  

Format must be

格式必须是

"fnServerParams": function ( aoData ) {
      aoData.push( { "name": "quizid", "value": quizid },{ "name": "questionid", "value": qid } );
},

#1


15  

Format must be

格式必须是

"fnServerParams": function ( aoData ) {
      aoData.push( { "name": "quizid", "value": quizid },{ "name": "questionid", "value": qid } );
},