Die*_*rea 3 ajax asp.net-mvc jquery
我有一个ajax表单,在数据库中保存一个对象,然后返回一个这样的消息:
return Json(new {Message = "Message!"},
JsonRequestBehavior.AllowGet);
Run Code Online (Sandbox Code Playgroud)
我们在这里很好,但我不知道我将如何在视图中获得此结果以在jQuery模式中显示.我的ajax表单如下所示,我想在OnSuccess方法上得到结果:
<%using (Ajax.BeginForm("Form", "Controller", new AjaxOptions() { OnSuccess = "MethodThatIWantToGetTheJson" }))%>
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
试试这个(摘自如何使用带有JSON结果的Ajax.BeginForm MVC助手?):
<%using (Ajax.BeginForm("Form", "Controller", new AjaxOptions() { OnComplete = "MethodThatIWantToGetTheJson" }))
<script type='text/javascript'>
function MethodThatIWantToGetTheJson(content) {
alert(content.get_response().get_object());
}
</script>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8155 次 |
| 最近记录: |