Jump to content

multiple ajax periodicalUpdater problem. (only works with 1 at a time)


shortysbest

Recommended Posts

I am building a website and it has a few notification areas that i am using ajax to automatically update on a set time, so far i have two functions that need to load onpage load, if i just have one function one works, but if i put the other that works, they wont work together though. So i was wondering why this might be?

 

<body onload="getEmail();getNotifications()">

 

/////////////////EMAIL NOTIFICATIONS/////////////////
//auto retrieve new emails
function getEmail()
{
   new Ajax.PeriodicalUpdater('email-notifier', 'php/notifications/get_emails.php', {
     method: 'get', frequency: 1, decay: 1
   });
setTimout("getEmail()", 6000);
}


////////////////NOTIFICATIONS///////////////
//friend requests
function getNotifications()
{
   new Ajax.PeriodicalUpdater('notifications', 'php/notifications/get_notifications.php', {
     method: 'get', frequency: 1, decay: 1
   });
setTimout("getNotifications()", 6000);
}

Link to comment
Share on other sites

A quick search shows you are using Prototype, but your logic is wrong. If you ever wanted to stop it, you'd want to assign that to a global variable. If not, just the following would work

new Ajax.PeriodicalUpdater('email-notifier', 'php/notifications/get_emails.php', {
     method: 'get', frequency: 1, decay: 1
   });

without the functions and javascript timeout.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.