Can jQuery do a POST of a ViewModel to a Controller in ASP.NET MVC?

后端 未结 2 854
时光说笑
时光说笑 2020-12-31 15:45

I have my Html Textboxes created so that they will be bound to a custom view model when posting back to the server.

<%= Html.TextBox(\"CustomerFormViewMod         


        
2条回答
  •  清酒与你
    2020-12-31 16:12

    It is possible, there is no difference between a "traditional POST" and "AJAX Post". For example:

    $.ajax({ type: "POST",
        url: '<%= Url.Action("AddCustomer", "Customer") %>',
        data: $('form').serialize(),
        success: function(data, textStatus) {
        }
    });
    

提交回复
热议问题