Skip to content

Instantly share code, notes, and snippets.

@dmishe
Created October 22, 2010 13:57
Show Gist options
  • Save dmishe/640576 to your computer and use it in GitHub Desktop.
Save dmishe/640576 to your computer and use it in GitHub Desktop.
Pure JS JSONP call
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