Home » Javascript » How do I load the functions of a JavaScript File called through a JavaScript Object

How do I load the functions of a JavaScript File called through a JavaScript Object

Posted by: admin August 19, 2018 Leave a comment

Questions:

I have a local JS file that needs to be called using a script object. However, I am not able to get the functions to run. Here’s the code snippet.

<script type="text/javascript">
 var x = document.createElement("SCRIPT");
 x.type = "text/javascript";
 x.src = "file:///C:/scripts/localscript.js";
 //one of the functions is loadData();
 loadData(); //I'm getting reference error, loadData is not defined.
</script>

Thank you,

Answers: