Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
JSONP + Google Ajax Apis
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
noiv  
View profile  
 More options Oct 31 2009, 8:37 pm
From: noiv <noi...@gmail.com>
Date: Sat, 31 Oct 2009 17:37:20 -0700 (PDT)
Local: Sat, Oct 31 2009 8:37 pm
Subject: JSONP + Google Ajax Apis
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#_...

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?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Aaron Newton  
View profile  
 More options Oct 31 2009, 11:22 pm
From: Aaron Newton <aa...@iminta.com>
Date: Sat, 31 Oct 2009 20:22:46 -0700
Local: Sat, Oct 31 2009 11:22 pm
Subject: Re: [Moo] JSONP + Google Ajax Apis

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){...});


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
noiv  
View profile  
 More options Nov 1 2009, 1:42 pm
From: noiv <noi...@gmail.com>
Date: Sun, 1 Nov 2009 10:42:08 -0800 (PST)
Local: Sun, Nov 1 2009 1:42 pm
Subject: Re: JSONP + Google Ajax Apis

> this.fireEvent('complete', args).fireEvent('success', args).callChain();

Works like a charm, arguments hides some magic...

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »