This is my code on shoutbox update :
function updateShoutbox(){
$("#shoutdiv").load("shoutbox.php", { 'action': 'update' } ,
function (responseText, textStatus, req) {
if (textStatus == "error") {
return false;
}
});
}
$(document).ready(function(){
updateShoutbox();
var auto_refresh = setInterval(
function ()
{
updateShoutbox();
$("#shoutdiv").scrollTop($("#shoutdiv")[0].scrollHeight);
}, 6000);
It returns error each some minutes :
shoutbox.php returned error:
Service Unavailable
Is there anyway to handle this error and hide it somehow ?
I edited my code so to stop showing any error on shoutbox update, but it still shows this error each minutes.
Ok, so let’s take this for example:
http://jsfiddle.net/userdude/6C8yp/
If you look at the console, you’ll see it counts down until
iis equal to0, oriis not given (that’s what the!!is for there). What I’m doing here is looping each second, but only after the last loop has finished. I’m feeding my loop.Looking at what you have here, I might do this instead:
http://jsfiddle.net/userdude/whsPn/
http://jsfiddle.net/userdude/whsPn/1/
Ok, so what we have above should mostly emulate the code you have in the question. You’ll note that I have the
complete: waitpart in there, and thesetTimeout()is in that callback. And.. it’s only called if thestatusreturned is200(success).Now, there you could turn
complete: waittosuccess: wait, and take out thestatus == 200if statement altogether. Of course, if you do want to run the update again, but maybe do something different, this is your chance.Also note, in the fiddle linked I’ve got some dummy code in there. So don’t just copy/page what’s in the fiddle, or you’ll have errors and it won’t run at all.
EDIT: Oops, found an error with
url =. Fixed.