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


Groups > comp.lang.javascript > #20552

Re: Ajax issue

Newsgroups comp.lang.javascript
Date 2013-07-05 07:48 -0700
References <492ccf76-c92f-4b97-85d9-1f1f926bedee@googlegroups.com> <f67e3cc5-5fad-4650-86ab-e7b6e9770b9e@googlegroups.com> <1372953269.FrdeS7i7de@PointedEars.de> <3c881e35-a08f-44b9-b514-510ba4023f91@googlegroups.com> <1650600.4TcKdCVReu@PointedEars.de>
Message-ID <5caf189e-ea6b-4fd3-9150-84fe9ccf68fd@googlegroups.com> (permalink)
Subject Re: Ajax issue
From Bart Van der Donck <bart@nijlen.com>

Show all headers | View raw


Thomas 'PointedEars' wrote:

> Well, you have probably nothing important to say anyway, 
> let alone something correct.

It is wise to first read and then conclude. Not the other way around.

> var xhr = new XMLHttpRequest();
> xhr.open("GET", "http://first.web.service.example", true);
> xhr.onreadystatechange = function () {
>   if (xhr.readyState == 4 && xhr.status == 200)
>   {
>     xhr.open("GET", "http://second.web.service.example", true);
>     xhr.onreadystatechange = function () {
>       // …
>     };
>     xhr.send(null);
>   }
> };
> xhr.send(null);
>
> or (W3C XMLHttpRequest API [1]):
> 
> var xhr = new XMLHttpRequest();
> xhr.open("GET", "http://first.web.service.example", true);
> xhr.onload = function () {
>   xhr.open("GET", "http://second.web.service.example", true);
>   xhr.onload = function () {
>     // …
>   };
>   xhr.send(null);
> };
> xhr.send(null);
>
> And there is no harm in that approach.  

Yes, there is. Reusing an XHR-object is simply not a reliable technology. Google 'reuse xhr object' gives a good overview of the involved issues and bugs, especially in MSIE.

>>> [...] it is wise to reuse variables that are no longer used.
>
>> Absolutely not! You only open the door to all kinds of
> misunderstandings, bugs and unnecessary complexity. […]
> 
> IBTD.

Ridiculous. See Google-search on 'variable reuse'. All advisories are clear: don't reuse variables!

-- 
 Bart

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