Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Alternative to Polling. HTML Updates

Tags:

html

ajax

polling

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

like image 203
joe_coolish Avatar asked Mar 23 '11 21:03

joe_coolish


2 Answers

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/

like image 73
Matijs Avatar answered Sep 29 '22 04:09

Matijs


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

like image 33
Naftali Avatar answered Sep 29 '22 05:09

Naftali