Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #20546

Re: Ajax issue

Message-ID <1372953269.FrdeS7i7de@PointedEars.de> (permalink)
From Thomas 'PointedEars' Lahn <PointedEars@web.de>
Organization PointedEars Software (PES)
Date 2013-07-04 16:26 +0200
Subject Re: Ajax issue
Newsgroups comp.lang.javascript
References <492ccf76-c92f-4b97-85d9-1f1f926bedee@googlegroups.com> <f67e3cc5-5fad-4650-86ab-e7b6e9770b9e@googlegroups.com>

Show all headers | View raw


Bart Van der Donck <bart@nijlen.com> wrote:
                    ^^^^^^^^^^^^^^^
Wrong, see RFC 5536 and <http://www.google.com/intl/en/policies/terms/>.

> saurabh...@gmail.com wrote:
>> I am trying to make 2 ajax calls on a button click in
>> javascript. The response of the first web service will
>> decide whether the second ajax calls should be made or
>> not. When I am trying to call the second web service
>> in the success function of the first one, I am able to
>> get the response but the HTML UI freezes. But if I
>> make a single ajax call and displays its response, it
>> works fine.
> 
> Some ideas:
>  
> 1. You're talking about calling [cit.] "the second web service in the
> success function of the first one". This is not recommended;

Wrong.

> it is better to cleanly finish the first AJAX-function before proceeding;

That has happened when the “success function of the first one” is called.

> 2. A 'setTimeout()'-function *might* *maybe* help;

Wrong.  A setTimeout() call will increase the risk of a timing problem as 
you can never know how long it takes to receive and process the first 
response.  Using the event listener is the safe approach.
  
> 3. Common 'XMLHttpRequest'-techniques typically use some variables. You
> would want to make sure that none of those are repeated in the second
> function,

Wrong.  Instead, it is wise to reuse variables that are no longer used.

> and that their scoping is correct;

Correct.  A common mistake is to use the same XHR object twice, while the 
response handling for the first request with that object is still in 
progress.  XHR libraries like JSX:http.js implement approaches that prevent 
that from happening.
  
> 4. Not to say that AJAX is bad, but similar techniques exist which form
> IMHO certainly a good alternative, such as iframes or server-side logic.

Utter nonsense.

-- 
PointedEars

Twitter: @PointedEars2
Please do not Cc: me. / Bitte keine Kopien per E-Mail.

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Ajax issue saurabh.khemka4@gmail.com - 2013-06-29 07:59 -0700
  Re: Ajax issue JJ <duh@nah.meh> - 2013-06-29 22:07 +0700
  Re: Ajax issue Bart Van der Donck <bart@nijlen.com> - 2013-07-04 00:33 -0700
    Re: Ajax issue Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-07-04 16:26 +0200
      Re: Ajax issue Bart Van der Donck <bart@nijlen.com> - 2013-07-05 01:15 -0700
        Re: Ajax issue Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-07-05 11:38 +0200
          Re: Ajax issue Bart Van der Donck <bart@nijlen.com> - 2013-07-05 07:48 -0700
            Re: Ajax issue Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-07-05 20:18 +0200
      Re: Ajax issue John Harris <niam@jghnorth.org.uk.invalid> - 2013-07-05 15:28 +0100
  Re: Ajax issue Matt Tacchi <mangamatt81@gmail.com> - 2013-07-11 00:34 -0700
    Re: Ajax issue Tim Streater <timstreater@greenbee.net> - 2013-07-11 09:34 +0100

csiph-web