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 6701481
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:56:21+00:00 2026-05-26T06:56:21+00:00

Through jQuery and the use of an ajax get I have a working model

  • 0

Through jQuery and the use of an ajax get I have a working model of a javascript process that polls a url and will either timeout or return successfully. The url is serviced by a small embedded box with a local httpd on it.

A php script issues a restart, waits a second, and then we go into the javascript code.

Before we can start our ajax get, we need to wait a while (about 90 seconds) to be assured that the server httpd has actually shut down. Otherwise our poll will work – and then our web page will crash when the server dies.

So to wait I have tried a number of ideas. Unfortunately the wait must be modal, that is nothing should happen until we timeout. What seems to work is a simple sleep() abstraction:

function sleep(milliseconds)
{
    var start = new Date().getTime();
    for (var i = 0; i < 1e7; i++)
    {
        if ((new Date().getTime() - start) > milliseconds)
        {
            break;
         }
     }
}

i = 0;
var cText='';
for (i = 0; i < 90; i++)
{
    sleep(1000);
    cText=cText+'.';
    $("#waitmessage").html(MakeFlushable(cText));
}
$.ajaxSetup( ...

Unfortunately this operates differently across browsers. After 30 seconds or so IE crashes. Mozilla (8) becomes apoplectic and eventually recovers when the ajax completes.

Thinking that the browser needs some response (in the form of anything) I tried writing a dot to a div. There is no browser output until the ajax event completes. I then tried appending a bunch of \n characters (4000 of them) for each dot (MakeFlushable() does this). Still, the dots don’t appear until ajax is done.

Thinking back to the old days there was a 4gl called CA Visual Objects which provided a method for handing control back to the “engine” in order that other housekeeping tasks be attended to. Perhaps this is what’s needed in this case? Is there a javascript call that says “do any housekeeping and then give me back control”? My guess is that the div html is not sent to the browser because javascript is stuck in my tight loop, waiting…

  • 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-05-26T06:56:21+00:00Added an answer on May 26, 2026 at 6:56 am

    Why not use setTimeout or setInterval to handle the timing for you?
    Do the ajax handling in the callback method.

    Something like:

    var SecondsToWait = 90;
    
    var secInterval = setInterval(oneSecIntervalHandler,1000);
    
    function oneSecIntervalHandler() {
        if (--SecondsToWait > 0) {
           $("#waitmessage").html( $("#waitmessage").html() + '.');
        } else {
            clearInterval(secInterval);
            //doAjaxStuffNow
            $("#waitmessage").html("doAjaxStuffNow...<br/>$.ajaxSetup( ...");
        }
    
    }
    

    jsfiddle: http://jsfiddle.net/qSwyQ/

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

Sidebar

Related Questions

I have a JavaScript application hosted at x.com which uses AJAX (through jQuery) to
Still working through JQuery to get data and repopulate portions of a page. Right
I'm doing an ajax request through jQuery and for example, my URL is http://test.com/query.php?hello=foo
I have a form. I am trying to validate it through AJAX GET requests.
I'm building a WordPress based AJAX site, where I use jQuery and the .get()
i use json_encode to send back data from php to jquery through ajax. and
So, basically I have this select / drop down menu that I use AJAX
I am trying to use Jquery to iterate through an array of textboxes where
I am trying to use JQuery to iterate through a number of <li> objects
I am trying to use jQuery to search through a list of links and

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.