Loading ...
Sorry, an error occurred while loading the content.

Re: Request.JSONP help. onComplete won't fire

Expand Messages
  • fractionofawhole
    Ahhh that worked perfectly. DOH! Thanks so much for the help, it s greatly appreciated.
    Message 1 of 3 , Sep 9, 2009
    View Source
    • 0 Attachment
      Ahhh that worked perfectly. DOH! Thanks so much for the help, it's greatly appreciated.

      --- In yws-flickr@yahoogroups.com, Sam Judson <sam@...> wrote:
      >
      > Try setting callbackKey to 'jsoncallback' and see were that gets you.
      >
      > Sam
      >
      > 2009/9/9 fractionofawhole <fractionofawhole@...>:
      > >
      > >
      > > Need some help using Request.JSONP with the Flickr API. I haven't been able
      > > to get a JSONP request to work without including the "jsoncallback"
      > > parameter. This is not a required parameter in the API url string and there
      > > is even a parameter to NOT have a JSON call back ("nojsoncallback=1"),
      > > however this isn't working for me either even though I follow the
      > > [url=http://www.flickr.com/services/api/response.json.html%5ddocumentation[/url].
      > > I don't want to have to define a call back function as I can't pass any kind
      > > of parameters to it. I want to handle everything in the onComplete handler
      > > of the Request. Below are 3 examples of various code setups as well as the
      > > associated firebug console output for each. Anyone with some Flickr API
      > > experience, or just any possible idea, I would greatly appreciate some
      > > advice.
      > >
      > > Ex: 1 - Successful in that it calls the assigned function in the
      > > "jsoncallback" attribute and the proper data is alerted, however the
      > > onComplete handler never fires.
      > >
      > > function infoHandler( data ) {
      > > alert( data.photo.description._content );
      > > }
      > >
      > > var setRequest = new Request.JSONP({
      > > url: 'http://api.flickr.com/services/rest/',
      > > data: {
      > > method: 'flickr.photos.getInfo',
      > > api_key: //api key goes here,
      > > photo_id: '3647421828',
      > > format: 'json',
      > > jsoncallback: 'infoHandler'
      > > },
      > > onComplete: function( data ) {
      > > alert( 'requet complete' );
      > > }
      > > }).send();
      > >
      > > Ex: 1 Console Output
      > > ["JSONP retrieving script with url:
      > > http://api.flickr.com/services/rest/?callback=Request.JSONP.request_map.request_0&method=flickr.photos.getInfo&api_key=api_key_here&photo_id=3647421828&format=json&jsoncallback=infoHandler"]
      > >
      > > Ex 2: - Passing the "nojsoncallback" parameter. JSON Output looks fine to me
      > > but fails due to a "invalid label". Not sure what that means. Again,
      > > onComplete handler never fires.
      > >
      > > var setRequest = new Request.JSONP({
      > > url: 'http://api.flickr.com/services/rest/',
      > > data: {
      > > method: 'flickr.photos.getInfo',
      > > api_key: //api key goes here,
      > > photo_id: '3647421828',
      > > format: 'json',
      > > nojsoncallback: '1'
      > > },
      > > onComplete: function( data ) {
      > > alert( 'requet complete' );
      > > }
      > > }).send();
      > >
      > > Ex: 2 Console Output
      > > ["JSONP retrieving script with url:
      > > http://api.flickr.com/services/rest/?callback=Request.JSONP.request_map.request_0&method=flickr.photos.getInfo&api_key=api_key_here&photo_id=3647421828&format=json&nojsoncallback=1"]
      > > invalid label
      > > {"photo":{"id":"3647421828", "secret":"9...:{"nsid":"8317957@N05",
      > > "username":"frac
      > >
      > > Ex: 3 - Does not include a "jsoncallback" or "nojsoncallback" parameter at
      > > all. Fails due to JSONFlickrAPI not being defined. Again, onComplete handler
      > > never fires.
      > >
      > > code
      > > var setRequest = new Request.JSONP({
      > > url: 'http://api.flickr.com/services/rest/',
      > > data: {
      > > method: 'flickr.photos.getInfo',
      > > api_key: //api key goes here,
      > > photo_id: '3647421828',
      > > format: 'json'
      > > },
      > > onComplete: function( data ) {
      > > alert( 'requet complete' );
      > > }
      > > }).send();
      > >
      > > Ex: 3 Console Output
      > > ["JSONP retrieving script with url:
      > > http://api.flickr.com/services/rest/?callback=Request.JSONP.request_map.request_0&method=flickr.photos.getInfo&api_key=api_key_here&photo_id=3647421828&format=json"]
      > > jsonFlickrApi is not defined
      > > rest?callback=Request.JSONP.request_map.request_0&method=flickr.photos.getInfo&api_key=api_key_here&photo_id=3647421828&format=json()
      > >
      > >
      >
    Your message has been successfully submitted and would be delivered to recipients shortly.