server got stuck

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

dell6400
Forum Newbie
Posts: 9
Joined: Fri Nov 20, 2009 8:21 pm
Contact:

Re: server got stuck

Post by dell6400 »

Yes it is in dedicated server. but I do not understand it how we can do this e.g., update countdown every 1 second but only ask server for updates every 5 seconds). how we can do it? could you tell me?
User avatar
iankent
Forum Contributor
Posts: 333
Joined: Mon Nov 16, 2009 4:23 pm
Location: Wales, United Kingdom

Re: server got stuck

Post by iankent »

dell6400 wrote:Yes it is in dedicated server. but I do not understand it how we can do this e.g., update countdown every 1 second but only ask server for updates every 5 seconds). how we can do it? could you tell me?
You need to setup multiple timers in your javascript code, i.e. one timer that does nothing but update the countdown timer display, and a second timer that does nothing but ask the server if there have been any updates. E.g.

Code: Select all

 
var updateTimer = 0;
var countdownTimer = 0;
function checkForUpdates() {
    // your ajax code to retrieve updates from server here
}
function updateCountdowns() {
    // your code to update countdown timers here
}
 
updateTimer = setInterval('checkForUpdates()', 5000); // check for udpates every 5 seconds
countdownTimer = setInterval('updateCountdowns()', 1000); // update the countdowns every 1 second
 
hth
dell6400
Forum Newbie
Posts: 9
Joined: Fri Nov 20, 2009 8:21 pm
Contact:

Re: server got stuck

Post by dell6400 »

Thanks dude...

I will try it and back to you again..

Thanks for your efforts :cry: :cry: ..
Post Reply