i execute a javascript with jQuery $.getScript. In the executed script i haven't access to the functions and variables of my source file.
Is there a solution?
i execute a javascript with jQuery $.getScript. In the executed script i haven't access to the functions and variables of my source file.
Is there a solution?
Nick Craver, I just spend 3 (!) hours obsessing over why my thing wouldn't work, and you gave me the insight I needed to make it work.
XOXOXOXOXOXOXOXO
interesting to note:
you can declare a variable as a jquery var like this:
That way jquery also has access to it from anywhere in the scope.
I found the answer here helpful for my grasp of the topic, but I still couldn't make it work in my own context until I happened upon this article on TechMonks:
When I copy/pasted their final example into the head of my main .js file it all just worked. For me at least, the $.getScript() function was broken, and this is the fix:
The script executed by $.getScript() does have access to the global context. You can use any global variable (or function for that matter) from within your external script.