8

I am working on a collaborative website that I want to give users notifications while they are viewing or editing data. Something similar to how in StackOverflow if you are replying to a question and the notification at the top pops up saying that there is a new reply to the post.

I can see how to do this using some kind of polling AJAX magic, but I was wondering if there was any way to push the notification to the browser w/o using polling?

Thanks for any help/ideas :)

EDIT:

For those interested, I went with SignalR https://github.com/SignalR/SignalR/wiki/Hubs

joe_coolish
  • 7,201
  • 13
  • 64
  • 111
  • you can't "push" to the client browser, it is disconnected environment, you will have to keep requesting for changes at some interval – Kris Ivanov Mar 23 '11 at 21:44

3 Answers3

6

Either use long polling for it to work in older browsers, or start reading up on eventSource:

http://dev.w3.org/html5/eventsource/

Nice article by Nicholas Zakas:

http://www.nczonline.net/blog/2010/10/19/introduction-to-server-sent-events/

Matijs
  • 3,118
  • 2
  • 29
  • 41
  • Long polling is something I had read about and thought it would work pretty well. But the html 5 stuff is exactly want I want. I hope it makes it into the final release! – joe_coolish Mar 24 '11 at 14:35
2

Well im starting to use Websockets (see some of my previous questions) and they are cool to use instead of ajax :-D

Naftali
  • 144,921
  • 39
  • 244
  • 303
1

Generally no, but there is a family of techniques that simulate such an effect.

Look into comet if you'd like to give it a shot: http://en.wikipedia.org/wiki/Comet_(programming)

joe_coolish
  • 7,201
  • 13
  • 64
  • 111
Kevin Dolan
  • 4,952
  • 3
  • 35
  • 47