将新数据加载到页面上而无需重新加载
我正在 ASP.Net 页面上进行高级规范,该页面可能会显示一些延迟的数据。
当页面加载时,呈现的初始数据将来自本地数据库(呈现速度会很快)。我想要的是一个单独的过程来寻找更新的数据(来自我拥有的任何其他服务)。这更耗时,但其想法是呈现数据,然后如果找到更新的数据,则将其动态附加到现有页面的顶部。
我想要一些关于如何实现这一目标的建议。
其技术范围是 ASP.Net 4.0、C# MVC3 和 HTML5。
谢谢。
I'm doing a high-level spec on an ASP.Net page which may have some delayed data presented.
When the page loads, the initial data presented will originate from a local database (which will be fast in presenting). What I want is a separate process to go out and look for updated data (from whatever other services I have). This is more time consuming, but the idea is to present data, then if newer data is found, append this, on the fly to the top of the existing page.
I would like some recommendations on how to accomplish this.
The tech scope for this is ASP.Net 4.0, C# MVC3 and HTML5.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
AJAX with jQuery 是实现这一目标的好方法。例如,您可以在标记上放置一个内容占位符 div:
然后一旦加载 DOM:
加载控制器操作将负责与远程服务通信并返回包含数据的部分视图:
现在如果这个 数据的获取是I/O密集型,您可以利用异步控制器和 I/O 完成端口,这将避免您在从远程源获取数据的漫长操作期间危及工作线程。
AJAX with jQuery is a good way to achieve this. So for example you could put a content placeholder div on your markup:
and then once the DOM is loaded:
where the Load controller action will take care of communicating with the remote services and return a partial view containing the data:
Now if this fetching of data is I/O intensive you could take advantage of asynchronous controllers an I/O Completion Ports which will avoid you jeopardizing worker threads during the lengthy operation of fetching data from a remote source.