I know this question has been answered many times but the solutions in those questions aren't working for me. I have a function in lets suppose, a.js. This function is outside the document.ready function and here is its format:
function thisIsFromAnotherFile(){
alert("This alert is from another js file");
}
I'm calling this function from the other file, b.js this way:
var openFile = function(context){
thisIsFromAnotherFile();
}
openFile is an onclick function.
onclick = "openFile(this)"
When I run this code I'm getting an Uncaught ReferenceError: thisIsFromAnotherFile is not defined. Please help me out. Thanks.
you need to load a.js before you call the function
It seems likely there's a few things you're not telling us. The following code provides a minimal, functioning example.
file1.html
filea.js
fileb.js