如何在 MVC5 中通过服务器端数据表 ajax 调用传递文本框值



我有一个服务器端数据表。

当我进行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")

最新更新