是否可以将 viewmodel 传递给使用 jQuery 调用它的控制器操作方法?目前在行动模型是空的。
控制器:
[HttpPost]
public ActionResult Action(MyModel model)
{
ProcessModel(model);
return Json(new
{
Result = "result"
});
}
jQuery:
function Serve() {
$.ajax({
type: "POST",
url: "/Controller/Action",
dataType: "json",
error: function (xhr, status, error) {
//Handle errors here...
},
statusCode: {
404: function (content) { alert('Cannot find resource'); },
505: function (content) { alert('Status code: 505'); },
500: function (content) { alert('Internal server error'); }
},
success: function (json) {
alert(json);
}
});
谢谢