Hi,
LE2. Any other ideas on how to fix this?
I have this code and can't figure why is not working properly:
$(function autorun() {
if ($("#contactForm").is(":visible")){
setInterval( "refreshAjax();", 150000000000 );
}
else {
setInterval( "refreshAjax();", 15000 );
}
setTimeout("autorun();", 2000)
});
...
<body onLoad="autorun()">
Right now it keep refreshing the page every 2 secs, even if the "contactForm" is visible.
My logic is: if the "contactForm" is visible, delay the refresh or stop it, keep checking that, but in the mean time refresh the page accordingly to the other statement.
LE.
$(function() {
refreshAjax = function(){$("#flex1").flexReload();
}
});
LE2. Final solution provided here by @Nick Craver
$(function () {
var ajaxTimeout;
function autorun() {
if ($("#contactForm").is(":visible")){
if(ajaxTimeout) {
clearInterval(ajaxTimeout);
ajaxTimeout = false;
}
}
else if(!ajaxTimeout) {
ajaxTimeout = setInterval(refreshAjax, 15000);
}
}
setInterval(autorun, 2000);
});
Thanks, Cristian.