浏览器的即时更新与AJAX / jQuery的 [英] browser instant updates with ajax/jquery

查看:110
本文介绍了浏览器的即时更新与AJAX / jQuery的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想逆向工程的Facebook如何处理自己的通知,在那里,当你得到你得到通过浏览器即时通知的消息。

I'm trying to reverse engineer how facebook handles their notifications, where when you get a message you get instantly notified via the browser.

我拨弄着它一点点,并意识到,总有一个未决的GET请求,听,如果你会从服务器某种更新。这似乎是某种形式的观察者模式。我只是想知道,如果这一模式被记录的地方。

I've fiddled with it for a little bit and realized that there is always a pending GET request "listening" if you will to some sort of update from the server. This appears to be some sort of observer pattern. I was just wondering if this pattern was documented somewhere.

推荐答案

该技术实际上是所谓的长轮询。这是流行彗星技术来解决传统的轮询的局限性之一。

The technique is actually called Long Polling. This is one of the popular Comet techniques to get around the limitations of traditional polling.

您可能想看看下面的堆栈溢出后一个很简单的例子:

You may want to check out the following Stack Overflow post for a very simple example:

更新:

在除了上述情况,我建议你看看接受的答案下面的堆栈溢出后的技术的详细描述:

In addition to the above, I suggest that you check out the accepted answer to the following Stack Overflow post for a detailed description of the technique:

  • <一个href="http://stackoverflow.com/questions/1086380/how-does-facebook-gmail-send-the-real-time-notification">How确实脸谱,Gmail中发送实时通知?

这篇关于浏览器的即时更新与AJAX / jQuery的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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