0

How does the notification area on Facebook works?
I'm taking about the automatically red box that appears.
If I have a message/something new on my wall.
I believe it is also in Stack Exchange, is that a Javascript interval?

Brian Tompsett - 汤莱恩
  • 5,195
  • 62
  • 50
  • 120
Asaf
  • 7,650
  • 17
  • 60
  • 109

2 Answers2

1

Please see this thread

How does one do realtime updates of a web page?

Community
  • 1
  • 1
kqnr
  • 3,520
  • 16
  • 15
0

Not sure about this, but I'd wager that both Facebook and SO use an implementation of Comet. Basically, you make a request to the server which is designed to be kept open a really long time, and the server only responds when it has something to say. When the request times out (or receives data back) you simply start up another one. This way you get as close to real-time data as you can without wasting a ton of bandwidth on empty requests.

Jimmy Sawczuk
  • 12,908
  • 7
  • 45
  • 60