Created
February 24, 2012 12:02
-
-
Save revolunet/1900561 to your computer and use it in GitHub Desktop.
JSONP loader
This file contains hidden or 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
| <script> | |
| function loadScript(src, callback){ | |
| var callbackParam = 'callback'; | |
| var s = document.createElement('script'); | |
| if (callback) { | |
| callback = callbackParam + '=' + callback; | |
| src += ((src.indexOf('?')==-1)?'?':'&')+callback; | |
| } | |
| s.src = src; | |
| document.body.appendChild(s); | |
| } | |
| </script> | |
| <button onclick="loadScript('https://api.github.com', 'alert')">JSONP load</button> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Does it remove the script tag after load ?