views:

82

answers:

2

I am building a website that has a system where users can send messages to each other. I would like it so that when a logged in user received a message, he would get some update on his screen telling him that.

These messages do not have to be in realtime, so I do not think I want to push with comet or juggernaut or anything like that. Instead, I would be happy to just poll the server every minute or so and listen for updates.

I am new to javascript, and I am wondering if there is a slick/right way to do this.

A: 

You could use a timer:

http://www.mcfedries.com/JavaScript/timer.asp

tbs
+3  A: 

Prototype has a periodicalUpdater, which would be the obvious choice in my opinion. Documented example:

new Ajax.PeriodicalUpdater('items', '/items', {
  method: 'get', frequency: 3, decay: 2
});
karim79