Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to invoke a "Please Wait" window only if ajax takes more than X milliseconds to respond?
    primarykey
    data
    text
    <p>I'm doing an AJAX call (regular JS) and, if it takes more than, say, 500 milliseconds, I'd like to put up my "Please Wait" box.</p> <p>Normally, if I want to put up the PW box immediately, I'd do:</p> <pre><code>// show semi-transparent grey screen to block access to everything underneath divGreyCoverAllNode.style.display = 'inline'; // show PW box. Prior to these lines, both coverall and PW were display=none divPleaseWaitNode.style.display = 'inline'; // now do the AJAX and follow-up inside a zero timer; the timer is necessary to // make the system pause to display the screen changes we previously invoked setTimeout( function() { // do my ajax call here, then after the call... // take down the PW stuff divPleaseWaitNode.style.display = 'none'; divGreyCoverAllNode.style.display = 'none'; }, 0 ); </code></pre> <p>Like I stated above, what I'd like to do is have the PW displayed only if AJAX doesn't finish in, say, 500 milliseconds. Ideally it would be something like:</p> <pre><code>// set a timer to display PW in 500 milliseconds myTimeEvent = setTimeout( function() { divGreyCoverAllNode.style.display = 'inline'; divPleaseWaitNode.style.display = 'inline'; }, 500 ); // do my ajax call here, then after the call... clearTimeout(myTimeEvent); // take down the PW stuff, in case it was displayed divPleaseWaitNode.style.display = 'none'; divGreyCoverAllNode.style.display = 'none'; </code></pre> <p>But I can't seem to get the system to pause and display the PW when AJAX is taking its time. I've tried surrounding the AJAX-and-follow-up block in a zero timer, but no deal.</p> <p>Any suggestions?</p> <p>EDIT: Important fact: This is <em>not</em> an asynch ajax call. It's an unusual situation that requires everything to wait on the ajax result.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload