Created
October 22, 2010 13:57
-
-
Save dmishe/640576 to your computer and use it in GitHub Desktop.
Pure JS JSONP call
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
function jsonp(url, callback, name, query) | |
{ | |
if (url.indexOf("?") > -1) | |
url += "&" + callback + "=" | |
else | |
url += "?"+ callback +"=" | |
url += name + "&"; | |
if (query) | |
url += encodeURIComponent(query) + "&"; | |
url += new Date().getTime().toString(); // prevent caching | |
var script = document.createElement("script"); | |
script.setAttribute("src",url); | |
script.setAttribute("type","text/javascript"); | |
document.body.appendChild(script); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment