Created
August 9, 2012 16:39
-
-
Save douglas-vaz/3305731 to your computer and use it in GitHub Desktop.
Cross domain request using callback added to a dynamic script element
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<!-- | |
Enter your script name in the text box and hit submit. Have a callback in the url and the form data. The callback function should execute. | |
--> | |
</head> | |
<body> | |
<form> | |
<input type="text" id="value"/> | |
<input type="button" id="sub" value="Submit" onclick="foo()"/> | |
</form> | |
<div id="dump"> | |
</div> | |
<script type="text/javascript"> | |
<!-- | |
function foo() | |
{ | |
var val = document.getElementById('value').value; | |
var url = val; | |
var elem = document.createElement('script'); | |
elem.setAttribute('type','text/javascript'); | |
elem.setAttribute('src',url); | |
document.body.appendChild(elem); | |
} | |
--> | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment