shortysbest Posted July 12, 2010 Share Posted July 12, 2010 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 https://forums.phpfreaks.com/topic/207465-multiple-ajax-periodicalupdater-problem-only-works-with-1-at-a-time/ Share on other sites More sharing options...
XeNoMoRpH1030 Posted July 12, 2010 Share Posted July 12, 2010 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 https://forums.phpfreaks.com/topic/207465-multiple-ajax-periodicalupdater-problem-only-works-with-1-at-a-time/#findComment-1084847 Share on other sites More sharing options...
shortysbest Posted July 12, 2010 Author Share Posted July 12, 2010 thanks, but that isn't working :| Link to comment https://forums.phpfreaks.com/topic/207465-multiple-ajax-periodicalupdater-problem-only-works-with-1-at-a-time/#findComment-1085004 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.