Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
JSONP
/*
* usage: JSONP.get("http://gdata.youtube.com/feeds/api/videos", {q:'lindsey','max-results':3,alt:'json',v:2}, console.log);
*/
var JSONP = (function(){
var counter = 0;
return {
get: function (url, params, callback) {
var cid = "json_" + counter++;
var query = "?";
var scriptTag = document.createElement("script");
var key;
for (key in params) {
query += key + "=" + encodeURIComponent(params[key]) + "&";
}
window[cid] = function(){
callback.apply(null, arguments);
document.head.removeChild(scriptTag);
delete window[cid];
}
scriptTag.src = url + query + "callback=" + cid;
scriptTag.async = "async";
document.head.appendChild(scriptTag);
}
};
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.