How to return a MVC View to a $.Ajax JSON POST

坚强是说给别人听的谎言 提交于 2020-01-04 04:16:44

问题


I am sending a $.Ajax POST to a MVC Controller function with parameters and returning a JasonResult successfully. What I need to happen is that the current View be returned (as if it was not a JSON request and I was returning the Viewdata). The Viewdata has been updated and the page needs to be redrawn.

In short, I want the MVC Action to respond back to the $Ajax request correctly, and then have the page redrawn using the updated Viewdata. Hope this makes sense, coming down with a bad cold.


回答1:


Jason result, awesome.

It doesn't work like that i'm afriad, either you need to not use ajax, or you need to return data and handle it in jquery, or you need to return a partial view.

Partial view is probably the best solution, you can just return a chunk of html and stick it in ur site, very simple to use.



来源:https://stackoverflow.com/questions/2611720/how-to-return-a-mvc-view-to-a-ajax-json-post

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!