fea*_*net 4 ajax actionresult ajax.beginform asp.net-mvc-2
什么是从Ajax MVC Action调用返回int的最简单方法?
我目前正在尝试:
public ContentResult Create(MyModel model)
{
return Content("1");
}
using (Ajax.BeginForm("Create",
new AjaxOptions {
OnComplete = "function(data) { alert(data); }"
}))
Run Code Online (Sandbox Code Playgroud)
我得到警报[object Object].我如何获得int值?或者如果可能的话直接返回int而不必使用ContentResult?
我会做这样的事情:
public JsonResult Create(MyModel model)
{
return Json(new { Result = 1 });
}
using (Ajax.BeginForm("Create",
new AjaxOptions {
OnComplete = "function(data) { alert(data.get_response().get_object().Result); }"
}))
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3582 次 |
| 最近记录: |