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


Groups > comp.lang.javascript > #11870

Re: how would i write this request in jquery?

Message-ID <1411017.V9SEqChMir@PointedEars.de> (permalink)
From Thomas 'PointedEars' Lahn <PointedEars@web.de>
Organization PointedEars Software (PES)
Date 2012-02-18 02:38 +0100
Subject Re: how would i write this request in jquery?
Newsgroups comp.lang.javascript
References <27298642.21.1329170666272.JavaMail.geo-discussion-forums@ynx13> <jhe7te$t31$1@dont-email.me>
Followup-To comp.lang.javascript

Followups directed to: comp.lang.javascript

Show all headers | View raw


Matt McDonald wrote:

> On 12-02-13 03:04 PM, Shawn Bright wrote:
>> Hey all, i have a request i am making with prototype that i need to do in
>> jquery.
>>
>> [Prototype.js code]
>>
>> appreciate any help.
> 
> Seeing as you're just jumping from one lost cause to another,
> I'll throw you a rope. What you're interested in using is
> actually the XMLHttpRequest API[0] which is often aliased
> as "AJAX" by marketers and fools.
> 
> Secondly, you'd be well-advised to steer clear of Prototype.js.
> Richard Cornford has a well-known quote here regarding it. I
> believe Thomas Lahn still has it randomly pop up in his "signature"
> from time to time. I'll give you a hint: it's pretty scathing.

As my sig is chosen randomly, and I do not want to look that one up right 
now, it is not the one you are looking for here.  But the one here is put 
equally aptly.
 
> I'd suggest digging through the XMLHttpRequest API
> documentation to understand how it truly works.

Looking into the newer XMLHttpRequest2 API would be useful as well, as there 
are implementations of it in browsers.  I have not had the time to consider 
it for JSX as yet, but it looks promising.

> That said, David Mark has a module in his My Library API[1] that
> covers "AJAX"[2]. I'd recommend at least giving it a
> test drive. It will mask warts in IE relating to ActiveX
> and other follies. For a clear beginner, that's a good idea.

The last time we discussed this here, David's code was slightly flawed in 
that it always used XMLHttpRequest() even if the request URI used the 
`file:' scheme (where XMLHttpRequest() is known not to work in MSHTML).  My 
code tries to use ActiveXObject() first which has no such limitations.
 
> [0] http://www.w3.org/TR/XMLHttpRequest/
> [1] http://www.cinsoft.net/mylib-builder.asp
> [2] http://www.cinsoft.net/mylib-doc.asp#requester

JFTR: Using JSX:http.js [1], which is (also?) built on (more) sound 
principles of software design, and rather well field-tested, that would be

  var Request = jsx.net.http.Request;

  var req = new Request("/sites/new_info", "GET", true,
    function (response) {
      var sites = response.responseJSON; 
    });

  req.send();

or

  var req = new Request("/sites/new_info");

  req.setSuccessListener(function (response) {
    var sites = response.responseJSON; 
  });

  req.send();

… assuming that `responseJSON' was a built-in host property.

Aliasing `Request' is optional then, of course, but it can improve 
efficiency if done in the right place.  jsx._import() would be another 
alternative.


PointedEars
_____
[1] <http://PointedEars.de/scripts/http.js>
    <http://PointedEars.de/websvn/filedetails.php?repname=JSX&path=/trunk/http.js>
-- 
Sometimes, what you learn is wrong. If those wrong ideas are close to the 
root of the knowledge tree you build on a particular subject, pruning the 
bad branches can sometimes cause the whole tree to collapse.
  -- Mike Duffy in cljs, <news:Xns9FB6521286DB8invalidcom@94.75.214.39>

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


Thread

how would i write this request in jquery? Shawn Bright <shawn@skrite.net> - 2012-02-13 14:04 -0800
  Re: how would i write this request in jquery? Andreas Bergmaier <andber93@web.de> - 2012-02-13 23:34 +0100
    Re: how would i write this request in jquery? Shawn Bright <shawn@skrite.net> - 2012-02-13 19:43 -0800
      Re: how would i write this request in jquery? Gene Wirchenko <genew@ocis.net> - 2012-02-13 20:35 -0800
  Re: how would i write this request in jquery? Hans-Georg Michna <hans-georgNoEmailPlease@michna.com> - 2012-02-14 17:20 +0100
  Re: how would i write this request in jquery? Matt McDonald <matt@fortybelow.ca> - 2012-02-14 11:07 -0700
    Re: how would i write this request in jquery? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-02-18 02:38 +0100

csiph-web