Asp.net MVC Ajax表单将Json返回到javascript方法

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)

有任何想法吗?

Luk*_*Led 5

试试这个(摘自如何使用带有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)