I'm looking for a way to refresh a specific div on my website that's used for chat. Here's the code I currently have:
var refreshId = setInterval(function() {
$('#chat_grab').load('chat_grab.php?randval=' + Math.random());
}, 5000);
The issue I'm facing is that if someone leaves the page open, this code will keep looping indefinitely. Is there a solution to make it timeout after, let's say, 10 minutes of the base page not being refreshed?