MVC 4与JQuery AJAX和部分视图 [英] MVC 4 with JQuery AJAX and Partial views

查看:53
本文介绍了MVC 4与JQuery AJAX和部分视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一个好的教程(我已经看过它们但找不到它们),这些教程将通过显示设置和开发基于MVC4的网站的正确方法,该网站使用异步加载的部分视图。在页面上为各个部分描绘带有少量加载GIF的网站。



我想用jquery创建它,它对控制器进行AJAX调用,然后加载模型,并为基础提供局部视图。然后,如果一个动作发生,它将进行一个AJAX调用(通常通过HttpPost)加载JSON。



所以我的小控件的流量是这样的:

整页响应加载一个包含调用AJAX调用的javascript的视图到控制器加载模型的局部视图。一旦页面加载($(document).ready),它将对服务器进行ajax调用以获得它的初始状态。

如果这个小控件有一些功能,那么它可以通过AJAX后续调用到控制器并返回基于JSON的数据(或偶尔返回另一个局部视图)。



是否有教程告诉我如何做到这一点?我已经经历了一些,但似乎都错过了一些难题。

I am looking for a good tutorial (I have seen them but can not find them) that would go through showing the proper way to setup and develop a MVC4 based website that uses partial views that load asynchronously. Picture the sites with the little loading gifs for the individual sections on the page.

I want to create it using jquery that makes an AJAX call to a controller that then loads the model with a partial view for the base. Then if an action occurs it would make an AJAX call (via HttpPost usually) that would load JSON.

So the flow of my little controls would be as such:
Full page response loads a view that contains javascript that makes an AJAX call to a controller that loads a partial view with the model. Once the page is loaded ($(document).ready) it would make the ajax call to the server to get it's initial state.
If this little control has some functionality to it then it can make subsequent calls via AJAX to the controller and be returned JSON based data (or occasionally another partial view).

Is there a tutorial that shows me how to do this? I have gone through some but all seem to be missing some piece of the puzzle.

推荐答案

(document).ready)它会对服务器进行ajax调用得到它的初始状态。

如果这个小控件有一些功能,那么它可以通过AJAX后续调用到控制器并返回基于JSON的数据(或偶尔返回另一个局部视图)。



是否有教程告诉我如何做到这一点?我已经经历了一些,但似乎都错过了一些难题。
(document).ready) it would make the ajax call to the server to get it's initial state.
If this little control has some functionality to it then it can make subsequent calls via AJAX to the controller and be returned JSON based data (or occasionally another partial view).

Is there a tutorial that shows me how to do this? I have gone through some but all seem to be missing some piece of the puzzle.


你正在寻找所有的东西,因为你可以在每篇文章/帖子中得到一些东西,只需选择你需要的东西然后继续前进。你不能得到一堆你需要的东西,只需要连接点;)

具有异步部分视图的MVC网站 [ ^ ]

使用Jquery Ajax渲染局部视图 [ ^ ]
You are searching for everything where as you can get something in each article/ posts, just pick what you needed and move on. You can not get a complete bunch of what you exactly need you just needs to 'connect the dots' ;)
MVC websites with asynchronous partial views[^]
Render Partial View using Jquery Ajax[^]


这篇关于MVC 4与JQuery AJAX和部分视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆