Would something like this work for you?
<script>
function tryReload(){
new Ajax.Request('/Task/reloadPage.htm',
{
method:'post',
parameters: { ... },
onSuccess: function(transport) {
if(transport == seconds){
// call self in x seconds
setTimeout(tryReload, (1000*transport));
}
else{ // transport is a URL
window.location = transport;
}
},
onFailure: function(){ ... }
});
}
//start it up!
tryReload();
</script>