jsonp.js revision afd6c54b4b2a0eb021233651a894e5a3ce3f1ca4
fc67d6c0ec40e25fd6756153861ebdb65e577014Dav Glass * <p>Provides a JSONPRequest class for repeated JSONP calls, and a convenience
100b8bd9adaf6900bd0dfb6083a8a788ca8cf23cDav Glass * method Y.jsonp(url, callback) to instantiate and send a JSONP request.</p>
100b8bd9adaf6900bd0dfb6083a8a788ca8cf23cDav Glass * <p>Both the constructor as well as the convenience function take two
100b8bd9adaf6900bd0dfb6083a8a788ca8cf23cDav Glass * parameters: a url string and a callback.</p>
100b8bd9adaf6900bd0dfb6083a8a788ca8cf23cDav Glass * <p>The url provided must include the placeholder string
100b8bd9adaf6900bd0dfb6083a8a788ca8cf23cDav Glass * "{callback}" which will be replaced by a dynamically
100b8bd9adaf6900bd0dfb6083a8a788ca8cf23cDav Glass * generated routing function to pass the data to your callback function.
100b8bd9adaf6900bd0dfb6083a8a788ca8cf23cDav Glass * An example url might look like
100b8bd9adaf6900bd0dfb6083a8a788ca8cf23cDav Glass * "http://example.com/service?callback={callback}".</p>
100b8bd9adaf6900bd0dfb6083a8a788ca8cf23cDav Glass * <p>The second parameter can be a callback function that accepts the JSON
100b8bd9adaf6900bd0dfb6083a8a788ca8cf23cDav Glass * payload as its argument, or a configuration object supporting the keys:</p>
3be83a94a2eca59b109251c4b7c99b99af927f82Dav Glass * <li>on - map of callback subscribers
100b8bd9adaf6900bd0dfb6083a8a788ca8cf23cDav Glass * <li>success - function handler for successful transmission</li>
100b8bd9adaf6900bd0dfb6083a8a788ca8cf23cDav Glass * <li>failure - function handler for failed transmission</li>
100b8bd9adaf6900bd0dfb6083a8a788ca8cf23cDav Glass * <li>timeout - function handler for transactions that timeout</li>
100b8bd9adaf6900bd0dfb6083a8a788ca8cf23cDav Glass * <li>format - override function for inserting the proxy name in the url</li>
100b8bd9adaf6900bd0dfb6083a8a788ca8cf23cDav Glass * <li>timeout - the number of milliseconds to wait before giving up</li>
100b8bd9adaf6900bd0dfb6083a8a788ca8cf23cDav Glass * <li>context - becomes <code>this</code> in the callbacks</li>
100b8bd9adaf6900bd0dfb6083a8a788ca8cf23cDav Glass * <li>args - array of subsequent parameters to pass to the callbacks</li>
100b8bd9adaf6900bd0dfb6083a8a788ca8cf23cDav Glass * @module jsonp
100b8bd9adaf6900bd0dfb6083a8a788ca8cf23cDav Glass * @submodule jsonp-base
100b8bd9adaf6900bd0dfb6083a8a788ca8cf23cDav Glass * @class JSONPRequest
100b8bd9adaf6900bd0dfb6083a8a788ca8cf23cDav Glass * @constructor
100b8bd9adaf6900bd0dfb6083a8a788ca8cf23cDav Glass * @param url {String} the url of the JSONP service
100b8bd9adaf6900bd0dfb6083a8a788ca8cf23cDav Glass * @param callback {Object|Function} the default callback configuration or
748017e442bd0838f8ff8cf53f67e6aaf31484e1Dav Glass * success handler
a2621d519886de7d60c30c5a0850f5c17fd2fb36Dav Glass * Set up the success and failure handlers and the regex pattern used
a2621d519886de7d60c30c5a0850f5c17fd2fb36Dav Glass * to insert the temporary callback name in the url.
d2a5a45ff58ab15a8ee0339edcd03f0243373d59Dav Glass * @method _init
fec0b12eb7538bebc558c3efe1c7f31e295cdc82Dav Glass * @param url {String} the url of the JSONP service
d2a5a45ff58ab15a8ee0339edcd03f0243373d59Dav Glass * @param callback {Object|Function} Optional success callback or config
d2a5a45ff58ab15a8ee0339edcd03f0243373d59Dav Glass * object containing success and failure functions and
0db84e0da684308b0fd9ea9b5906c11bafa7a246Dav Glass * the url regex.
0db84e0da684308b0fd9ea9b5906c11bafa7a246Dav Glass * @protected
100b8bd9adaf6900bd0dfb6083a8a788ca8cf23cDav Glass // Accept a function, an object, or nothing
context: this,
args : [],
_defaultCallback: function () {},
send : function () {
function (data) {
* @method Y.jsonp
noop = function () {},
bracketAlias = {},
if (match) {
callback = getByPath(Y.config.win, path) ||