The*_*att 9 ajax asp.net-mvc jquery viewmodel
我创建了我的Html文本框,以便在发回服务器时将它们绑定到自定义视图模型.
<%= Html.TextBox("CustomerFormViewModel.Email")%>
Run Code Online (Sandbox Code Playgroud)
如果它是传统的POST,这很有效.然后我可以在Controller端接收它,如下所示:
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult AddCustomer(CustomersFormViewModel model)
{
//validate data, save customer, handle validation errors...
}
Run Code Online (Sandbox Code Playgroud)
我想知道 - 是否可以通过jQuery进行POST并仍然获得相同的行为?
eu-*_*-ne 16
有可能,"传统POST"和"AJAX Post"之间没有区别.例如:
$.ajax({ type: "POST",
url: '<%= Url.Action("AddCustomer", "Customer") %>',
data: $('form').serialize(),
success: function(data, textStatus) {
}
});
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
4337 次 |
最近记录: |