Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #19433
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!mx05.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| From | "Tony" <tony.johansson@inport.com> |
| Newsgroups | comp.lang.javascript |
| Subject | Why can't I wait for a flag that is set in an synchronous function |
| Date | Wed, 24 Apr 2013 15:12:38 +0200 |
| Organization | A noiseless patient Spider |
| Lines | 1 |
| Message-ID | <kl8lib$509$1@dont-email.me> (permalink) |
| Mime-Version | 1.0 |
| Content-Type | text/plain; format=flowed; charset="iso-8859-1"; reply-type=original |
| Content-Transfer-Encoding | 7bit |
| Injection-Date | Wed, 24 Apr 2013 13:09:31 +0000 (UTC) |
| Injection-Info | mx05.eternal-september.org; posting-host="04290fff4557273ca84c3ad616751e0b"; logging-data="5129"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/c/6vI2Av966aDa8Wnu9cJCUmywVQFb54=" |
| X-MimeOLE | Produced By Microsoft MimeOLE V15.4.3555.308 |
| X-Newsreader | Microsoft Windows Live Mail 15.4.3555.308 |
| Importance | Normal |
| Cancel-Lock | sha1:gdke1l4MKPUn1aXoK50I7rB3mto= |
| X-Priority | 3 |
| X-MSMail-Priority | Normal |
| Xref | csiph.com comp.lang.javascript:19433 |
Show key headers only | View raw
The function GetBooking() is using asynchronous communication to get data
from the database.
I want to wait by using the while loop until the ready flag is set in the
GetBooking function to true and then continue with the array that was
loaded in the
GetBooking().
I use setInterval to call a function CheckUntilAsyncComplete that will check
if the ready flag has been set to true.
This works only if I add an alert to the while loop.
It seems to me that if I don't have an alert It will execute and never call
the CheckUntilAsyncComplete
$(function () //wait until the DOM writing is complete
{
GetBooking();
status = setInterval(CheckUntilAsyncComplete()', 1000);
while (!ready)
{
//alert("Looping");
}
//Here I want to use the array that is filled in GetBooking()
});
function CheckUntilAsyncComplete()
{
if (ready)
{
clearInterval(status);
}
}
//Tony
Back to comp.lang.javascript | Previous | Next — Next in thread | Find similar | Unroll thread
Why can't I wait for a flag that is set in an synchronous function "Tony" <tony.johansson@inport.com> - 2013-04-24 15:12 +0200 Re: Why can't I wait for a flag that is set in an synchronous function JJ <duh@nah.meh> - 2013-04-25 01:49 +0700
csiph-web