MrMastermind Posted February 28, 2007 Share Posted February 28, 2007 Hi, We're currently testing an auction timer which updates the auction clock every second and als updates the price accordingly, using Ajax Prototype periodicalupdater() and javascript setInterval(). During testing we noticed that sometimes the clock skips a few seconds. Now I can imagine that this is due to the load the server gets from every update it has to do for every visitor that attends the auction. I can also imagine that this gets worse when more visitors attend the auction. So the question is, am I correct about the load? And is there a way to make sure the updates occur correctly for every visitor, giving them an equal change at the auction? Would it be possible to use a server-side push? or do we need to switch to another language other than PHP for that? Here's most of the code used for the clock: if (window.ActiveXObject){ var http; var timerID = 1; function dataHandle() { if ( http.readyState == 4 ) { var response = http.responseText; document.getElementById('klok').innerHTML = response; } } function UpdateTimer() { http.open('POST', 'veiling/aflopende_klok.php'); http.onreadystatechange = dataHandle; http.send(document.getElementById('klok').innerHTML); timerID = setTimeout("UpdateTimer()", 1000); } function StartTijd() { // Firefox, IE7, etc.. if (window.XMLHttpRequest){ http = new XMLHttpRequest(); } // IE 6.0, ect.. else if (window.ActiveXObject){ http = new ActiveXObject("Microsoft.XMLHTTP"); } timerID = setTimeout("UpdateTimer()", 1000); } StartTijd(); }else{ var url = 'veiling/aflopende_klok.php'; new Ajax.PeriodicalUpdater( 'klok', url, {asynchronous:true, frequency:1, method:'get'} ); } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.