Goal: Get javascript to work concurrently with Ajax.Updater (prototype.js)
Purpose: I am creating a website that displays a list of servers, and updates server status's every 10 seconds (without refreshing the page). So I use the Ajax.Updater to call a function every 10 seconds to update every server's status. (Please refer to my other post)
Get every UL element's ID for a specific class
Problem: It seems to be that the Ajax.Updater interferes with any javascript I am using on that same page (ex. drop down menu will not drop down anymore, fancy pop up windows wont pop up either, etc). When I comment out the Ajax.Updater script, my javascript works great without any problem. The following is my ajax.updater code:
<script type="text/javascript">
function startUpdateTimer(item) {
setInterval(function () { new Ajax.Updater(item.id, 'update.php?url=' + item.id); }, 10000);
}
$$('ul.SBUpdater').each(startUpdateTimer);
</script>
Would anyone know开发者_StackOverflow why this is happening or how to fix this? Also, if you would suggest doing this a different way, I am open to ideas!
Also, I would suggest using the Ajax.PeriodicalUpdater instead of Ajax.Updater. It will handle the timing for you and can be done with less code.
Sounds like you already have a Javascript library(probably jQuery) running on your site already. If that's true you should remove PrototypeJS and use whatever library that's already on there for you ajax updater. Using multiple js libraries isn't the best solution.
精彩评论