Web自动刷新/更新 [英] Web automatic refresh/updates

查看:63
本文介绍了Web自动刷新/更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先让我说实话 - 我还没有为此编写任何代码 - 我只是在寻找建议......我是C#开发人员。

我打算开发一个应用程序(Web)并希望像Facebook(FB)一样自动更新,当FB上的朋友发帖/评论,页面没有轻弹,时间和评论自动发布。我正在寻找类似的东西 - 我不是在做聊天应用程序。解释一切都需要时间 - 这是个人项目。



对阅读材料的参考将会有所帮助,谢谢。

First let me be honest - I haven''t wrote any code for this - I am only looking for an advice... I am C# developer.
I am planning to develop an application (Web) and want automatic update like Facebook (FB), on FB when a friend post/comment, the page does not flicks, the time and posting of comments automatically. I looking for something like that - I am not doing a chat application. Explaining all will take time - It''s a personal project.

A reference to reading material will be helpful, thanks.

推荐答案

有很多方法可以完成你所追求的目标,所以我只想简单介绍一种方法。



您将使用 setTimeout setInterval (在 JavaScript 中)定期对进行 AJAX 调用网络服务检查新内容。当您从Web服务获取新内容时(可能以 JSON 的形式),您将使用JavaScript(可能是 jQuery )来更新 DOM元素所以页面显示新内容。



如果您想阅读材料,我建议使用Google上面的粗体术语。也许最好还是读一两本书;也许其中一个涉及AJAX,另一个涉及AJAX / Web服务。



ASP.NET MVC 将是Web服务的替代方案,因为它也可以通过AJAX从服务器轻松返回JSON以供JavaScript处理。为此,你要考虑从动作方法返回JSON。
There are many ways to accomplish what you''re after, so I''ll just give a brief summary of one approach.

You''d use setTimeout or setInterval (in JavaScript) to periodically make AJAX calls to a web service to check for new content. When you get new content from the web service (perhaps in the form of JSON), you''d use JavaScript (perhaps jQuery) to update the DOM elements so the page shows the new content.

If you want reading material, I recommend Googling the above bolded terms. Probably best to read a book or two as well; perhaps one of them about AJAX and another that involves AJAX/web services.

ASP.NET MVC would be an alternative to web services, as it too can easily return JSON from the server via AJAX to be processed by JavaScript. For that, you''d want to look into returning JSON from action methods.


这篇关于Web自动刷新/更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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