Received: by 10.224.116.5 with SMTP id k5mr289141qaq.19.1257045788390; Sat, 31 Oct 2009 20:23:08 -0700 (PDT) Received: by 10.224.116.5 with SMTP id k5mr289140qaq.19.1257045788348; Sat, 31 Oct 2009 20:23:08 -0700 (PDT) Return-Path: Received: from qw-out-2122.google.com (qw-out-2122.google.com [74.125.92.26]) by gmr-mx.google.com with ESMTP id 25si453898qyk.3.2009.10.31.20.23.07; Sat, 31 Oct 2009 20:23:07 -0700 (PDT) Received-SPF: pass (google.com: domain of anut...@gmail.com designates 74.125.92.26 as permitted sender) client-ip=74.125.92.26; Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of anut...@gmail.com designates 74.125.92.26 as permitted sender) smtp.mail=anut...@gmail.com; dkim=pass (test mode) header...@gmail.com Received: by qw-out-2122.google.com with SMTP id 9so266118qwb.39 for ; Sat, 31 Oct 2009 20:23:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:received:in-reply-to :references:from:date:x-google-sender-auth:message-id:subject:to :content-type; bh=Yvz7eeg7vMTIJbmIBn0Y9FQHmVj+mZQ+tWgWf6CSqVs=; b=AXIS6yBnGYf+sYA+3leWym7SPPbY2NOeJzztlXVOzmH/bJjebb3wlKEExYp5Z2pXyH tbbzjg+98elOKoL7ecQUWeq7dZrxVJDDZFZ4hPJJWW+u7nfUfZlscEiScaxI31k09NEG 2jdlHCU++rFiKhlRNJaREPwRm4J830Ot+Cb2o= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:from:date :x-google-sender-auth:message-id:subject:to:content-type; b=lkXqqoSs9b/Wt2AGKaM8PVqGpgK5GK4f/pwoNzVnJDIAh5T4OjBgormkLpAFzaHdbp hmAo+wtnAvzDLrHzk+9Sh7oi+nDki+XmV6vqrxenvQ+KtPMRMQcp4GgB1JRsfFgFs0Ry T4zjYxxK/RFcAxEwM46+Lm/65r7kCIZfoZtZA= MIME-Version: 1.0 Sender: anut...@gmail.com Received: by 10.224.59.130 with SMTP id l2mr2011090qah.73.1257045787162; Sat, 31 Oct 2009 20:23:07 -0700 (PDT) In-Reply-To: References: From: Aaron Newton Date: Sat, 31 Oct 2009 20:22:46 -0700 Message-ID: <26ac76760910312022r6431506bwf8a181cf2535b...@mail.gmail.com> Subject: Re: [Moo] JSONP + Google Ajax Apis To: mootools-users@googlegroups.com Content-Type: multipart/alternative; boundary=00c09f99deaf9c3ae2047746c70f --00c09f99deaf9c3ae2047746c70f Content-Type: text/plain; charset=ISO-8859-1 That looks reasonable; I think it would make a good change in the code; I'll update the class for the next release. To make it work properly, you'll need to update the success method: success: function(args, script){ if (script) script.destroy(); this.running = false; this.log('JSONP successfully retrieved: ', args); this.fireEvent('complete', args).fireEvent('success', args).callChain(); } they key being that the arguments are applied as they are, and not wrapped in an array (so fireEvent('complete', args) not fireEvent('complete', [args]). Now your complete event will be passed all the arguments: myJSONP.addEvent('complete', function(contextValue, responseObject, responseStatus, errorDetails){...}); On Sat, Oct 31, 2009 at 5:37 PM, noiv wrote: > > Hi, > > I want to use the google ajax api to get news in different languages > and display them with a tab control. The usual result does not know > the language, but I can use a context parameter. Unfortunately the > result then looks like this: > > callbackFunction( > contextValue, // the context arg value > responseObject, // the collection of results and cursor > responseStatus, // 200 on success, non-200 on failure > errorDetails) // error string for non-200 response > > note 4 parameters here. > http://code.google.com/apis/ajaxsearch/documentation/reference.html#_fonje_args > > The request uses onComplete : this.displayResult.bind(this) which > works fine without the context param, because the API answers with > only one param then. > > I had a look into the code of mootools-1.2.4.1-more and replaced > 'data' with 'arguments' here: > > Request.JSONP.request_map['request_' + index] = function(data) > { this.success(arguments, script); }.bind(this); > > Now my function is called with an array of all the api arguments. > > Is it safe to continue with this little diff or did I miss any side- > effects? > --00c09f99deaf9c3ae2047746c70f Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable That looks reasonable; I think it would make a good change in the code; I&#= 39;ll update the class for the next release.

To make it work pr= operly, you'll need to update the success method:

= success: function(args, script){
if (script) script.destroy();
<= span class=3D"Apple-tab-span" style=3D"white-space:pre"> this.runni= ng =3D false;
this= .log('JSONP successfully retrieved: ', args);
this.fireEvent('= complete', args).fireEvent('success', args).callChain();
}

they key being that the arguments are applied a= s they are, and not wrapped in an array (so fireEvent('complete', a= rgs) not fireEvent('complete', [args]).

Now your complete event will be passed all the argument= s:

myJSONP.addEvent('complete', function(c= ontextValue, responseObject, responseStatus, errorDetails){...});

On Sat, Oct 31, 2009 at 5:37 PM, noiv <= span dir=3D"ltr"><noi...@gmail.com> wrote:

Hi,

I want to use the google ajax api to get news in different languages
and display them with a tab control. The usual result does not know
the language, but I can use a context parameter. Unfortunately the
result then looks like this:

callbackFunction(
=A0contextValue, =A0 =A0// the context arg value
=A0responseObject, =A0// the collection of results and cursor
=A0responseStatus, =A0// 200 on success, non-200 on failure
=A0errorDetails) =A0 =A0// error string for non-200 response

note 4 parameters here.
http://code.goog= le.com/apis/ajaxsearch/documentation/reference.html#_fonje_args

The request uses onComplete : this.displayResult.bind(this) which
works fine without the context param, because the API answers with
only one param then.

I had a look into the code of mootools-1.2.4.1-more and replaced
'data' with 'arguments' here:

Request.JSONP.request_map['request_' + index] =3D function(data) { this.success(arguments, script); }.bind(this);

Now my function is called with an array of all the api arguments.

Is it safe to continue with this little diff or did I miss any side-
effects?

--00c09f99deaf9c3ae2047746c70f--