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


Groups > comp.lang.javascript > #11743 > unrolled thread

how would i write this request in jquery?

Started byShawn Bright <shawn@skrite.net>
First post2012-02-13 14:04 -0800
Last post2012-02-18 02:38 +0100
Articles 7 — 6 participants

Back to article view | Back to comp.lang.javascript


Contents

  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

#11743 — how would i write this request in jquery?

FromShawn Bright <shawn@skrite.net>
Date2012-02-13 14:04 -0800
Subjecthow would i write this request in jquery?
Message-ID<27298642.21.1329170666272.JavaMail.geo-discussion-forums@ynx13>
Hey all, i have a request i am making with prototype that i need to do in jquery.


var url = "/sites/new_info";
new Ajax.Request(url, {
    method: 'get',
    onSuccess: function(response) {
    var sites = response.responseJSON; 
    }
});

appreciate any help. 

[toc] | [next] | [standalone]


#11745

FromAndreas Bergmaier <andber93@web.de>
Date2012-02-13 23:34 +0100
Message-ID<jhc36j$sv9$2@news.albasani.net>
In reply to#11743
Shawn Bright schrieb:
> Hey all, i have a request i am making with prototype that i need to do in jquery.

Have you read the docs?

> var url = "/sites/new_info";
> new Ajax.Request(url, {
>      method: 'get',
>      onSuccess: function(response) {
>      var sites = response.responseJSON;
>      }
> });

That code does what you have coded. Whats wrong with it?

  Bergi

[toc] | [prev] | [next] | [standalone]


#11749

FromShawn Bright <shawn@skrite.net>
Date2012-02-13 19:43 -0800
Message-ID<27ea0e06-da06-4a3b-aba7-6707e85efe22@d15g2000yqg.googlegroups.com>
In reply to#11745
On Feb 13, 4:34 pm, Andreas Bergmaier <andbe...@web.de> wrote:
> Shawn Bright schrieb:
>
> > Hey all, i have a request i am making with prototype that i need to do in jquery.
>
> Have you read the docs?
>
> > var url = "/sites/new_info";
> > new Ajax.Request(url, {
> >      method: 'get',
> >      onSuccess: function(response) {
> >      var sites = response.responseJSON;
> >      }
> > });
>
> That code does what you have coded. Whats wrong with it?
>
>   Bergi

oh, it works fine, but i need to do the same thing in jQuery.

[toc] | [prev] | [next] | [standalone]


#11750

FromGene Wirchenko <genew@ocis.net>
Date2012-02-13 20:35 -0800
Message-ID<r2pjj7hs37hbes819odumaa2i1n1npfitc@4ax.com>
In reply to#11749
On Mon, 13 Feb 2012 19:43:33 -0800 (PST), Shawn Bright
<shawn@skrite.net> wrote:

[smip]

>oh, it works fine, but i need to do the same thing in jQuery.

     Why?  What does it gain you?

Sincerely,

Gene Wirchenko

[toc] | [prev] | [next] | [standalone]


#11752

FromHans-Georg Michna <hans-georgNoEmailPlease@michna.com>
Date2012-02-14 17:20 +0100
Message-ID<9c2lj7pvhk0c0rt63ucknluhktqss2kcpr@4ax.com>
In reply to#11743
On Mon, 13 Feb 2012 14:04:26 -0800 (PST), Shawn Bright wrote:

>Hey all, i have a request i am making with prototype that i need to do in jquery.

>var url = "/sites/new_info";
>new Ajax.Request(url, {
>    method: 'get',
>    onSuccess: function(response) {
>    var sites = response.responseJSON; 
>    }
>});

jQuery is not very popular here, to put it mildly.

It may be a good idea to visit jQuery's own forum and ask there.
I'm pretty sure you will get the answer there.

Hans-Georg

[toc] | [prev] | [next] | [standalone]


#11761

FromMatt McDonald <matt@fortybelow.ca>
Date2012-02-14 11:07 -0700
Message-ID<jhe7te$t31$1@dont-email.me>
In reply to#11743
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.

I'd suggest digging through the XMLHttpRequest API
documentation to understand how it truly works. 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.

[0] http://www.w3.org/TR/XMLHttpRequest/
[1] http://www.cinsoft.net/mylib-builder.asp
[2] http://www.cinsoft.net/mylib-doc.asp#requester


-- 
Matt McDonald: Web/Flash Developer; Edmonton, Alberta, Canada

[toc] | [prev] | [next] | [standalone]


#11870

FromThomas 'PointedEars' Lahn <PointedEars@web.de>
Date2012-02-18 02:38 +0100
Message-ID<1411017.V9SEqChMir@PointedEars.de>
In reply to#11761
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>

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.javascript


csiph-web