如何做网站立即使用AJAX更新自己的内容?自己的、如何做、内容、网站

由网友(不抽烟只抽你)分享简介:今天,当我在两个不同的浏览器使用Google+,我贴的东西用一个浏览器。后几乎立即出现在第二个浏览器(有可能延时0.5秒的)。谷歌是如何实现这一目标?难道他们不断发送Ajax请求,以检查是否有新的职位?这岂不是投入了大量的应变在服务器上?Today, when I was using Google+ in two s...

今天,当我在两个不同的浏览器使用Google+,我贴的东西用一个浏览器。后几乎立即出现在第二个浏览器(有可能延时0.5秒的)。谷歌是如何实现这一目标?难道他们不断发送Ajax请求,以检查是否有新的职位?这岂不是投入了大量的应变在服务器上?

Today, when I was using Google+ in two separate browsers, I posted something with one browser. The post almost instantly appeared on the second browser (there was maybe 0.5 seconds of delay). How does Google achieve this? Do they constantly send AJax requests to check for new posts? Wouldn't this put a lot of strain on the server?

推荐答案

有多种方法可用于执行此操作:

There are a variety of methods can be used to do this:

的WebSockets AJAX长轮询 页计时器 内置页框

每个人都有自己的警告和可能性。

Each one has it's own caveats and possibilities.

如果您有兴趣能够做一个实时的应用程序,你可以看看 socket.io 这是所有这些技术的巨大抽象库,所以它会使用哪种最好支持在您的浏览器之一。

If you're interested in being able to do a real-time application, you might have a look at socket.io which is a great abstraction library for all of these technologies, so it'll use the one which is best supported in your browser.

阅读全文

相关推荐

最新文章