javascript - How does StackOverflow know when there are new answers to a question? - Stack Overflow

If this question has already been asked I appologies, please point me in the right direction.I was wond

If this question has already been asked I appologies, please point me in the right direction.

I was wondering if anyone has any insight into how StackOverflow pops up the "n new answers have been posted, load new answers" thing at the top of a question when you are adding a post. This seems like a very useful function for my forum web-site and I would like to know how it is done. I assume some ajax or advanced javascript of some kind.

If this question has already been asked I appologies, please point me in the right direction.

I was wondering if anyone has any insight into how StackOverflow pops up the "n new answers have been posted, load new answers" thing at the top of a question when you are adding a post. This seems like a very useful function for my forum web-site and I would like to know how it is done. I assume some ajax or advanced javascript of some kind.

Share Improve this question edited Mar 10, 2014 at 12:12 rene 42.5k78 gold badges121 silver badges165 bronze badges asked Oct 30, 2008 at 15:00 user18411user18411 2
  • 1 Edited to make this more clearly a real question. – Chris Marasti-Georg Commented Oct 30, 2008 at 15:03
  • That is a much better question then mine, thanks :) – user18411 Commented Oct 30, 2008 at 15:17
Add a ment  | 

2 Answers 2

Reset to default 12

Look at this SO blog post: https://blog.stackoverflow./2008/10/solving-the-fastest-gun-in-the-west-problem/

That said, the one implementable remendation that came out of this discussion is an active, GMail like notification when you are posing an answer. We agreed with this feature request, so Jarrod implemented it. Here’s how it works:

  1. When you start posing a reply, a timer is created.
  2. Every minute, the page checks itself to see if new answers have arrived.
  3. If new answers arrive, the notification bar will tell you how many, and offer to update the page for you.
  4. Answer updates are performed AJAX style, so they don’t interrupt your current answer.

At a guess it's using a jQuery timer object to query a JSON webservice every n seconds. Check out http://docs.jquery. and Link.

How ironic... an answer has been posted as I was writing this.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1743932764a4532112.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信