I am trying to call an external js file from another js file. Here is my code:
file1.js
function func1(id){
var NewScript= document.createElement('script')
NewScript.src="file2.js"
document.body.appendChild(NewScript);
func2(id);
}
file2.js
function func2(id)
{
alert("im here " +id);
}
But when I ran it it gives out the "func2 is not defined. " Am i doing it right?
Can somebody help me?
Thanks