Reputation: 794
How can I pass a variable via $getScript()
to the called js-file here bfile.js
.
var x = new Array();
$.getScript('bfile.js', x);
I called it normally because I read that in the new called javascript file all variables are visible but for the variable x
, I get a Uncaught ReferenceError: x is not defined.
Please help!
Upvotes: 0
Views: 897
Reputation: 24302
you don't need to pass variables. just declare the variable as global variable before load the script. then it will available for any script load after that.
Upvotes: 1