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


Groups > comp.lang.javascript > #9001

Re: How to Create an XHR (Ajax) Object

Message-ID <1663325.JFYEL58v44@PointedEars.de> (permalink)
From Thomas 'PointedEars' Lahn <PointedEars@web.de>
Organization PointedEars Software (PES)
Date 2011-12-08 23:45 +0100
Subject Re: How to Create an XHR (Ajax) Object
Newsgroups comp.lang.javascript
References <c8822aed-a1a2-4009-a65d-686b79090c3e@s26g2000yqd.googlegroups.com> <jbpf64$d8r$1@news.albasani.net> <1810376.7NaK4W3vae@PointedEars.de>
Followup-To comp.lang.javascript

Followups directed to: comp.lang.javascript

Show all headers | View raw


Thomas 'PointedEars' Lahn wrote:

> - The `call' call is pointless.  Your constructor does _not_ *return* a
>   reference to another object (as a factory would), so it returns a
>   reference to an "empty" Object instance:
> 
>     return new (window.XMLHttpRequest = function XMLHttpRequest() {
>       ActiveXObject.call(this, "Microsoft.XMLHTTP");
>     });
> 
>   evaluates to
> 
>     window.XMLHttpRequest = function XMLHttpRequest() {
>       ActiveXObject.call(this, "Microsoft.XMLHTTP");
>     };
> 
>     return new window.XMLHttpRequest();

That is not entirely accurate (`x = y` evaluates to the value of _`y'_ if 
not in JavaScript 1.2 compliance mode), but you get the idea.
 
>   which, assuming for a moment `call' works here, can be broken down into
> 
>     var previousXHR = window.XMLHttpRequest;
> 
>     window.XMLHttpRequest = function XMLHttpRequest() {
>       ActiveXObject.call(previousXHR, "Microsoft.XMLHTTP");
>     };
> 
>     return new window.XMLHttpRequest();
> 
>   which evaluates to the equivalent of
> 
>     return {};

PointedEars
-- 
Prototype.js was written by people who don't know javascript for people
who don't know javascript. People who don't know javascript are not
the best source of advice on designing systems that use javascript.
  -- Richard Cornford, cljs, <f806at$ail$1$8300dec7@news.demon.co.uk>

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


Thread

David Mark's Daily Javascript Tips  - Volume #3 - Tip #10 - How to Create an XHR (Ajax) Object David Mark <dmark.cinsoft@gmail.com> - 2011-12-07 15:36 -0800
  Re: How to Create an XHR (Ajax) Object Andreas Bergmaier <andber93@web.de> - 2011-12-08 05:41 +0100
    Re: How to Create an XHR (Ajax) Object David Mark <dmark.cinsoft@gmail.com> - 2011-12-08 11:23 -0800
    Re: How to Create an XHR (Ajax) Object Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-12-08 23:12 +0100
      Re: How to Create an XHR (Ajax) Object Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-12-08 23:45 +0100
      Re: How to Create an XHR (Ajax) Object David Mark <dmark.cinsoft@gmail.com> - 2011-12-08 16:38 -0800
        Re: How to Create an XHR (Ajax) Object Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-12-09 11:50 +0100
          Re: How to Create an XHR (Ajax) Object David Mark <dmark.cinsoft@gmail.com> - 2011-12-09 12:08 -0800
            Re: How to Create an XHR (Ajax) Object Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-12-10 20:56 +0100

csiph-web