Created
August 28, 2015 14:49
-
-
Save JosePedroDias/427a8f86af9cda6b2b3c to your computer and use it in GitHub Desktop.
JSONP (not perfect)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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