[ 2 posts ]

jrussbowman

  • Joined: Sat Oct 10, 2009 10:22 am
  • Posts: 7
  • Offline
  • Profile

Calling jsonp more than once on a page fails

Post Posted: Sat Jan 09, 2010 12:25 pm
+0-
I set up a simple test here - http://www.hatethegame.net/jsonp/

Basically, jsonp works if you call it once, but all calls after that do nothing, and also throw no error. From what I can see in firebug, it's not making any network requests.

Luke Smith

YUI Contributor

  • Username: lsmith
  • Joined: Thu Aug 28, 2008 7:50 am
  • Posts: 511
  • Location: Sunnyvale
  • Twitter: ls_n
  • GitHub: lsmith
  • Gists: lsmith
  • IRC: ls_n
  • YUI Developer
  • Offline
  • Profile

Re: Calling jsonp more than once on a page fails

Post Posted: Sun Feb 07, 2010 10:46 pm
+0-
What was likely happening was due to the Loader being optimized not to pull down a module twice. The previous architecture used Loader to fetch the JSONP in a new sandbox by assigning it to a static module name '_'.

I've refactored it to use the Get util (for a few reasons) and added a few niceties on while I was in there. Now it supports parsing the callback from the url string as well as context override, additional args, and a new timeout hook.

Config signature changed though. The callbacks are now inside an 'on' property to be more in accordance with the rest of the library. E.g.

Code:
Y.jsonp( url, {
    on: {
        success: someObject.doMyBidding
    },
    context: someObject,
    args: [ "these will appear", "after the JSON object", "as the 2nd, 3rd, and 4th params to doMyBidding" ]
} );
  [ 2 posts ]
Display posts from previous:  Sort by  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum