0

我有一个购买表格来根据模型接收一些数据,但这里我在控制器中的 purchase_return 对象没有接收任何数据。它正在接收 productId 0 和 productNm null。谁能指出这里发生了什么?的HTML:

<form id="Purchase_ReturnForm">
    <div>
        <table>
            <tr>
                <td>
                    @Html.LabelFor(model => model.ProductId)
                </td>
                <td>
                    @Html.TextBoxFor(model => model.ProductId)
                </td>
                <td>
                    <input type="button" id="btnFind" value="Find" />
                </td>
            </tr>
            <tr>
                <td>
                    @Html.LabelFor(model => model.ProductNm)
                </td>
                <td>
                    <span id="edit">
                        @Html.TextBoxFor(model => model.ProductNm)
                    </span>
                </td>
            </tr>
        </table>
    </div>
</form>  

剧本:

 <script>
    $(document).ready(function () {
        $('#btnFind').click(function () {
            var data = $('Purchase_ReturnForm').serialize();
            $.ajax({
                type: 'Post',
                url: '/Purchase_Return/FindProductInvoice',
                data: data,
                success: function () {

                }
            })
        });
    });
</script> 

在控制器中:

public ActionResult FindProductInvoice(Purchase_Return purchase_Return)
    {
        return View();
    }

和模型

 public class Purchase_Return
{
    //public DateTime ReturnDt { get; set; }
    //public int ReturnSl { get; set; }
    //public DateTime PurchaseDt { get; set; }
    //public int PurchaseSl { get; set; }
    //public double TotReturnAmt { get; set; }
    //public double TotVat { get; set; }
    //public double TotDiscount { get; set; }
    //public int CustomerSupplyId { get; set; }
    [Display(Name="Product")]
    public int ProductId { get; set; }
    public string ProductNm { get; set; }
    //public double PurchaseRt { get; set; }
    //public double PurchaseQty { get; set; }
    //public double ProductDisAmt { get; set; }
    //public double ProductVat { get; set; }
    //public string ReturnNote { get; set; }
    //public int InsertUserId { get; set; }
}
4

1 回答 1

1

添加 # 登录您的数据,因为您正在使用 id 选择器来捕获表单数据。

$('#Purchase_ReturnForm').serialize()

它应该按您的预期工作。

于 2018-07-08T08:31:34.690 回答