I have a javascript located on URL http://www.example.com/script.js.
When run, the script returns a UUID in the following format:
var uuid="AAAABBBBCCCCDDDD";
Every call to the JavaScript returns a random unique string.
I have a simple HTML page with a single text box on it. I need to call the JavaScript before the page loads and put the above result into the textbox.
I tried to use jQuery:
$.get(URL,callback);
But that didn't work; No results were returned.
How to I call an external JavaScript and put the result inside the textbox?
EDIT: Here is the code I used:
<script language="javascript">
$(window).bind("load",start);
function start()
{
alert("Inside");
alert($.getScript("http://www.example.com/script.js")
}
</script>
I'm using this code inside a system that generated its own HTML code and I can't modify the <head>
tag, so adding the JavaScript code there isn't an option.
I tried using the above but it seems to break the code as no alert is shown. If I remove the jQuery part, the "Inside" alert is shown.
Do I need to reference jQuery in some way in order for it to work? Is there another way to import JavaScript code without modifying the <head>
tag?