I recently coded this code below that updates my div every 0.5 seconds (500ms) and I want it to only update if you have new content for the box
function refreshOnline() {
$('#toupdate').load('http://frosthotel.co.uk/refreshstats', function() {
$(this).unwrap();
});
}
refreshOnline();
setInterval(function() {
refreshOnline();
}, 500);
You can use $.get, $.post or $.ajax instead of $.load and compare the return value on ajax callback function and update if necessary.
function refreshOnline() {
$.get('http://frosthotel.co.uk/refreshstats', function(data) {
if(data!=$('#toupdate').html()) $('#toupdate').html(data);
});
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With