Jquery DataTable将参数传递给ajax调用asp.net [英] Jquery DataTable passing a parameter to ajax call asp.net
问题描述
ajax:{
dataType:$ {
$ b
$ 'json',
contentType:application / json; charset = utf-8,
type:POST,
url:index.aspx / Risky ,
dataSrc:function(json){
return $ .parseJSON(json.d);
}
},
columns:[
{data:Prctice_Group_Risk_No},
{data:Practice_Group},
{data:Risk_Category},
]
});
我的问题是我如何传递这个ajax调用的参数?我已经看到无处不在的网络,但所有这些例子是关于服务器端处理的地方,但在这里我正在使用客户端处理,我没有使用fnsServerData或fnServerParams,任何人可以帮助我知道如何传递参数与我的ajax调用?
使用 ajax.data
选项可以在Ajax请求时添加或修改提交给服务器的数据。
数据表({
ajax:{
dataType:'json',
contentType :application / json; charset = utf-8,
type:POST,
url:index.aspx / Risky,
data函数(d){
d.extra_search = $('#extra')。val();
},
dataSrc:function(json){
return $ .parseJSON(json.d);
}
},
columns:[
{data:Prctice_Group_Risk_No},
{data :Practice_Group},
{data:Risk_Category},
]
});
below is my code in which I send an ajax call to my web method and get data from server to populate my HTML table, as you can see I am using Jquery DataTables to accomplish the task, and it is working fine
$('#example').DataTable({
"ajax": {
"dataType": 'json',
"contentType": "application/json; charset=utf-8",
"type": "POST",
"url": "index.aspx/Risky",
"dataSrc": function (json) {
return $.parseJSON(json.d);
}
},
"columns": [
{ "data": "Prctice_Group_Risk_No" },
{ "data": "Practice_Group" },
{ "data": "Risk_Category" },
]
});
my question is how can i pass a parameter with this ajax call? I have seen everywhere on net but all those examples are about where its server side processing but here i am am using client side processing , I am not using fnsServerData or fnServerParams , Can anyone help me know how to pass a parameter with my ajax call?
Use ajax.data
option to add or modify data submitted to the server upon an Ajax request.
$('#example').DataTable({
"ajax": {
"dataType": 'json',
"contentType": "application/json; charset=utf-8",
"type": "POST",
"url": "index.aspx/Risky",
"data": function (d) {
d.extra_search = $('#extra').val();
},
"dataSrc": function (json) {
return $.parseJSON(json.d);
}
},
"columns": [
{ "data": "Prctice_Group_Risk_No" },
{ "data": "Practice_Group" },
{ "data": "Risk_Category" },
]
});
这篇关于Jquery DataTable将参数传递给ajax调用asp.net的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!