window.onload = setupRefresh;
function setupRefresh() {
setInterval("refreshBlock();", 1000);
}
function refreshBlock() {
$('#activeItems').load("current_auctions.php");
}
the above code automatically refreshes the content of a div tag on my page every 1 second.
window.onload = setupRefresh;
function setupRefresh() {
setInterval("refreshBlock();", 1000);
}
function refreshBlock() {
if ($('#myAccount').html() == 'My Accout') {
$('#activeItems').load("current_auctions.php");
};
}
The above code, which only has the addition of an if statement, loads up the page once in the beginning, and then ceases to refresh. How can I fix this code?
Probably because that conditional is returning false.
Quite likely because of the typo in ‘Accout’, as @nnnnn says.
You can debug this quite easily in Chrome or Firefox by using a script terminal. In Firefox you could install Firebug or in Chrome just press Crtl+Shift+J. Either way get to a JavaScript command-line interface and enter:
In your page. You’ll see it return either
trueorfalse. If it’sfalseyou can then easily tweak that condition until it’struewhere you’re expecting.