Ajax form serialize doesnt bind when using multiple parameters in MVC Controller

前端 未结 2 1449
梦如初夏
梦如初夏 2021-01-06 05:44

I have a view with multiple inputs for my Model (Html.TextBoxFor(x => x.attribute) etc. And my ajax method is:

function callMethod() {
    $.ajax({
        t         


        
2条回答
  •  情话喂你
    2021-01-06 05:52

    you can do it like this:

    function callMethod() {
        var number = 2;
        var sd = $('#Form').serializeArray();
        sd.push({ name:"test", value:number });
    
        $.ajax({
            type: "POST",
            data: sd,
            url: '@Url.Action("formMethod", "Test")',
        }).done(function (newTable) {
            $('#RefundTableDiv').html(newTable);
        });
    };
    

提交回复
热议问题