如何在jquery datatable的ajax调用中发布参数 [英] How to post the parameter in ajax call of jquery datatable
本文介绍了如何在jquery datatable的ajax调用中发布参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
到目前为止,我正在数据表的ajax调用中将参数和URL一起传递.
As of now I am passing parameter along with URL in ajax call of data table.
但是我想将其作为POST
方法传递,请任何人帮助我有关post方法中传递参数的问题,这是我的试用代码:
But I want to pass it as POST
method, please anyone one help me regarding parameter passing in post method, here's my trial code:
// Sending through GET
var $table = $('#example').dataTable(
"processing": true,
"serverSide": true,
"bDestroy": true,
"bJQueryUI": true,
"ajax": 'getResult.php?formName=afscpMcn&action=search&mcn_no='+mcnNum+'&cust_nm='+cust_num+'&emp_id='+emp+''
});
推荐答案
就像在POST方式中像普通jQuery ajax一样传递它.
Just pass it like a normal jQuery ajax in POST fashion.
结构应如下所示:
ajax: { type: 'POST', url: <path>, data: { your desired data } }
示例:
var $table = $('#example').dataTable(
"processing": true,
"serverSide": true,
"bDestroy": true,
"bJQueryUI": true,
"ajax": {
'type': 'POST',
'url': 'getResult.php',
'data': {
formName: 'afscpMcn',
action: 'search',
// etc..
},
}
});
在PHP中,只需照常访问POST索引(只是简单的方法):
In PHP, just access the POST indices as usual (just the straightforward approach):
getResult.php
$form_name = $_POST['formName'];
// the rest of your values ...
这篇关于如何在jquery datatable的ajax调用中发布参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文