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?
Asked
Active
Viewed 96 times
0

Brian Tompsett - 汤莱恩
- 5,753
- 72
- 57
- 129

Asaf
- 8,106
- 19
- 66
- 116
2 Answers
1
Please see this thread
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
- 13,488
- 7
- 46
- 60