我有一个服务器端数据表。
当我进行ajax
调用时,它不会在文本框中发送给定的值,而是发送空值。
当我传递静态数据时,它工作正常。
这很好:
var table = $("#tblUsers").DataTable({
"language":
{
"processing":
"<div class='overlay custom-loader-background'><i class='fa fa-cog fa-spin custom-loader-color'></i></div>"
},
"processing": true,
"serverSide": true,
"ajax":
{
"url": "/Client/GetData",
"type": "POST",
"dataType": "JSON",
'data': ({ ZoneID: zoneIDs })
},
"columnDefs": [
{
"targets": [0],
"width": "5%",
"hidden": true,
}
],
"fnRowCallback": function (nRow, aData, iDisplayIndex, iDisplayIndexFull) {
//console.log(nRow);
$(nRow).find("td:eq(0)").attr("hidden", true);
return nRow;
},
"columns": [
{
"data": "ClientDetailsID"
}]
});
但是当我从文本框值而不是静态数据传递zoneid
时,它会发送空数据。
"data": { ZoneID: $("#txtSOmething").val() }
将data
更改为
data: function(d){
d.myValue = $("#txtSOmething").val();
}
在服务器上查找 myValue 在Request
中。例如,asp mvc: Request.Form.Get("myValue")