如何返回一个MVC视图到$就JSON POST视图、MVC、POST、JSON

2023-09-10 19:41:25 作者:然而

我送一个$就张贴到MVC控制器的功能与参数,并成功返回JasonResult。我需要发生的是,当前视图返回(因为如果它不是一个JSON的请求,我返回可视数据)。在可视数据已更新,网页需要重新绘制。

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.

总之,我想MVC的行动来响应到$ Ajax请求正确,然后在使用更新的可视数据的页面重新绘制。希望这是有道理的,下来了重感冒。

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.

推荐答案

杰森结果,真棒。

它不工作,这样我是不是畏惧,无论你需要不使用AJAX,或者你需要在jQuery的返回数据,并处理它,或者你需要返回的局部视图。

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.

部分观点可能是最好的解决方案,你可以返回一个HTML块,并把它贴在乌拉圭回合的网站,使用起来非常简单。

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.