Well, I can honestly say i'm not great with javascript at all. Never really learned it. Problem is I want the script to keep checking the database at small intervals, but I only want the <div> to update when something's changed.
Basically the big problem is this: The user can't click a link that's being updated every half-second. My solution was to update the links only when there's a new one available.
Unless anyone else has another solution to this, it seems quite logical. I just can't seem to get it to work
When the user focuses the div just clearInterval(X)
One they off focus run refpage again.
This way it keeps checking but will pause when they want to do something. 500ms seems a little quick. Remember to watch out for the rapid Ajax stuff, 5 users at 2 requests per second is 600 server hits a minute. Imagine if you had 1000 people.
Thanks, that's brilliant. I downed it to three seconds, but I think i'll just up the speed depending on how many friends the user has (more friends=more chances per second(s) someone's going to be online/offline)
Once I get a new computer the server'll be able to handle it. Just need that check...
Cool, glad it worked. Also, remember that you might get back cached data with your request, if you want a unique guaranteed response from each ajax call add a random variable to the end, e.g. friends.php?rnd="+Math.random(),true