Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9020339
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T04:59:31+00:00 2026-06-16T04:59:31+00:00

This is my code on shoutbox update : function updateShoutbox(){ $("#shoutdiv").load("shoutbox.php", { ‘action’: ‘update’

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T04:59:32+00:00Added an answer on June 16, 2026 at 4:59 am

    Ok, so let’s take this for example:

    $(document).ready(function(){
        (function iterate(i) {
            if (!!i) {
                console.log('iteration #', i--);
    
                setTimeout(function next(){
                    iterate(i);
                }, 1000);
            }
        })(10);
    });​
    

    http://jsfiddle.net/userdude/6C8yp/

    If you look at the console, you’ll see it counts down until i is equal to 0, or i is 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:

    $(document).ready(function($){
        var $shoutbox = $("#shoutdiv"),
            timer;
    
        (function update(){
            var opts = {
                url: 'shoutbox.php',
                action: 'update',
                complete: wait
            };
    
            $.ajax(opts);
    
            function wait(res, status, req){
                if (status == 200) {
                    $shoutbox
                        .append(res)
                        .scrollTop($shoutbox[0].scrollHeight);
    
                    timer = setTimeout(update, 6000);
                }
            }
    
        })();
    });​
    

    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: wait part in there, and the setTimeout() is in that callback. And.. it’s only called if the status returned is 200 (success).

    Now, there you could turn complete: wait to success: wait, and take out the status == 200 if 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.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This code disabled mouse scroll functionality, when i click on the document. $(document).on(click, function
This code is returning blank array. I am posting to PHP script with code.
This code doesn't work what's wrong? $(.re).focus(function() { if($(this).attr(type) == text) { $(this).attr(type, password);
This code does not seem to run well: http://jsfiddle.net/5GEru/1/ var left = 0; function
I am borrowing this code that was entering strings (user, message) into shoutbox table
This is my code <?php header(Content-type: text/css; charset: UTF-8); // Admin Color Define //
This code selects cell values in MySQL and manually adds them to PHP variables:
I'm looking at some code for a shoutbox at yensdesigns , and in this
This code below allows me to find the word error in all my files
This code is the core of a much larger script that works great in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.