admin管理员组文章数量:1360344
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
2 Answers
Reset to default 12Look 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:
- When you start posing a reply, a timer is created.
- Every minute, the page checks itself to see if new answers have arrived.
- If new answers arrive, the notification bar will tell you how many, and offer to update the page for you.
- 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.
本文标签: javascriptHow does StackOverflow know when there are new answers to a questionStack Overflow
版权声明:本文标题:javascript - How does StackOverflow know when there are new answers to a question? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743932764a2564146.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论