YUILibrary - Open source JavaScript and CSS for building richly interactive software.
Fork YUI on GitHub
  • Home
  • Gallery
  • Forums
  • YUI 2
  • YUI 3
  • YUICompressor
  • YUIDoc
  • More
  • Gallery Forums
  • Gallery Stats
  • Gallery Calendar
  • Register
  • Login

Modules

  • Home
  • Featured
  • Popular
  • New
  • All

Documentation

  • FAQ
  • Developer FAQ
  • Developer Guide
  • Module Setup

Context Navigation

    YUI Library is not responsible for bugs or support with this module. It is available as a free service. For support please contact the module owner with the provided links.

    JSONP (gallery-jsonp)

    Last Updated: 02/8/10
    + 0 -

    Luke Smith

    YUI Developer

    See 6 more by this user.

    Featured Item

    Created: 10/24/09
    Last CDN Push: 02/10/10
    Build Tag: gallery-2010.02.10-01
    Project: YUI 3
    License: YUI BSD
    YUI Version: 3.0.0
    Free for use.

    Provides a JSONPRequest class for repeated JSONP calls, and a convenience method Y.jsonp(url, callback) to instantiate and send a JSONP request.

    The callback for the response can be named in the url explicitly or provided in the configuration (second parameter to the constructor).

    By default, the query parameter string &quot;callback=???&quot; will be searched for in the url (??? can be anything). If it's not found, it will be added on. If the JSONP service uses a different parameter name or url format, you can override this behavior with the <code>format</code> property in the callback config.

    The second parameter can be a callback function that accepts the JSON payload as its argument, or a configuration object supporting the keys:

    * on - map of callback subscribers
    * success - function handler for successful transmission
    * failure - function handler for failed transmission
    * timeout - function handler for transactions that timeout
    * format - override function for inserting the proxy name in the url
    * timeout - the number of milliseconds to wait before giving up
    * context - becomes <code>this</code> in the callbacks
    * args - array of subsequent parameters to pass to the callbacks

    • Tags:
    • jsonp
    • lsmith
    • Download
    • Docs
    • Homepage
    • Bugs
    • Source
    • Example
    • Forum
    • History

    Code Sample

    YUI({
        modules: {
            'gallery-jsonp': {
                fullpath: 'http://yui.yahooapis.com/gallery-2010.02.10-01/build/gallery-jsonp/gallery-jsonp-min.js',
                requires: ['get','oop'],
                optional: [],
                supersedes: []
          }
     
        }
    }).use('gallery-jsonp', function(Y) {
     
        var url = "http://query.yahooapis.com/v1/public/yql?" +
                      "q=select%20*%20from%20upcoming.events%20" +
                      "where%20woeid%20in%20" + 
                      "(select%20woeid%20from%20geo.places%20" +
                      "where%20text%3D%22North%20Beach%22)" +
                      "&format=json&diagnostics=false";
     
        var upcoming = Y.one('#upcoming');
     
        Y.jsonp(url, function (data) {
            Y.each(data.query.results.event, function (o) {
                upcoming.append("<h3>" + o.name + "</h3><p>" + o.description + "</p>");
            });
        });
     
    });

    Forum Posts

    Subject Author Date
    Calling jsonp more than once on a page fails jrussbowman 01/9/10
    Re: Calling jsonp more than once on a page fails Luke Smith 02/8/10
    YUI Projects
    • All YUI Downloads
    • YUI 2
    • YUI 3
    • YUIDoc
    • YUICompressor
    • YUILibrary.com
    • YUI Build Tool
    • YUI PHP Loader
    Pages & Links
    • All YUI Downloads
    • Git FAQ
    • Graded Browser Support
    • Contribute to YUI
    • Forum Stats
    • Gallery Stats
    • YUI Calendar
    Contribute
    • Submit a Bug
    • Request a Feature
    • Write Code
    • Meet the Team
    Follow YUI
    • on GitHub
    • on Twitter
    • on FriendFeed
    • on Facebook
    • on IRC
    • YUI Blog
    • YUI Theater
    • YUI Forums

    © 2010 YUI Library - Site Credits