Skip to content

Instantly share code, notes, and snippets.

@JosePedroDias
Created August 28, 2015 14:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JosePedroDias/427a8f86af9cda6b2b3c to your computer and use it in GitHub Desktop.
Save JosePedroDias/427a8f86af9cda6b2b3c to your computer and use it in GitHub Desktop.
JSONP (not perfect)
var pendingsJsonpCbs = [];
var jsonp = function(uri, cb) {
pendingsJsonpCbs.push(cb);
var scriptEl = document.createElement('script');
scriptEl.setAttribute('type', 'text/javascript');
scriptEl.setAttribute('src', uri + '&jsonp=parseJSON');
document.head.appendChild(scriptEl);
};
var parseJSON = function(o) {
pendingsJsonpCbs.shift()(o);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment