On Dec 3, 3:00*pm, pbd22 <dush...@gmail.com> wrote:
> On Dec 2, 1:12*pm, David Mark <dmark.cins...@gmail.com> wrote:
>
>
>
> > On Dec 2, 2:52*pm, pbd22 <dush...@gmail.com> wrote:
>
> > > Hi.
>
> > > It seems my xmlhttp response is taking too long. I have something like
> > > this:
>
> > > try
> > > {
> > > if (a === "")
> > > err += "some error";
>
> > > if (b==="")
> > > err += "some error";
>
> > > if (c==="")
> > > {
> > > err += "some error";}
>
> > > else
> > > {
> > > // use an xmlhttp request to compare a condition
> > > // that must be evaluated from the server. the response
> > > // is true or false.
>
> > > }
> > > }
>
> > > catch{}
>
> > > finally{
>
> > > if (err ==="")
> > > //submit the form
> > > else
> > > //let the user know about the errors.
>
> > > }
>
> > > THE PROBLEM is that the logic does not publish the response of the
> > > Ajax request
> > > because the round-trip takes too long. I have tested this by adding an
> > > alert. If the alert
> > > fires and then I click off the alert dialog, the appropriate response
> > > from the Ajax request
> > > is in the error list. But, otherwise, it seems like the time it takes
> > > to respond is omitting the
> > > response in the error list.
>
> > > Is there a way in JavaScript in an If/Else scenario to force getting
> > > the appropriate response
> > > from the Ajax request before the next code block is evaluated?
>
> > > Thanks in advance.
>
> > You would have to use a synchronous request, which is a very bad idea
> > for a browser script. *Change your design to suit an asynchronous
> > request.
>
> OK, thanks. Would you mind providing some pseudo code to give me a
> sense of things?
>
> Thanks again.
See the FAQ notes for an example.
|