Created
March 7, 2018 15:06
-
-
Save samuel-fonseca/fbf558753d0a737cbe7b66a312d4f174 to your computer and use it in GitHub Desktop.
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
// source: https://stackoverflow.com/questions/2499567/how-to-make-a-json-call-to-a-url/2499647#2499647 | |
function getJSONP(url, success) { | |
var ud = '_' + new Date, | |
script = document.createElement('script'), | |
head = document.getElementsByTagName('head')[0] | |
|| document.documentElement; | |
window[ud] = function(data) { | |
head.removeChild(script); | |
success && success(data); | |
}; | |
script.src = url.replace('callback=?', 'callback=' + ud); | |
head.appendChild(script); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment