Skip to content

Instantly share code, notes, and snippets.

@samuel-fonseca
Created March 7, 2018 15:06
Show Gist options
  • Save samuel-fonseca/fbf558753d0a737cbe7b66a312d4f174 to your computer and use it in GitHub Desktop.
Save samuel-fonseca/fbf558753d0a737cbe7b66a312d4f174 to your computer and use it in GitHub Desktop.
// 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