javascript - Using Jquery's .getScript is it possible to pass variables to your current script -


this question has answer here:

say have js file stores singular object. in js script need access object. can use .getscript or there way? when try use .getscript variables set outside of scope , update in getscript scope not update.

given following html:

<script type="text/javascript" src="jquery-2.0.3.min.js"></script> <script>     var external = false;     $.getscript('test.js', function(){         console.log(external);     }); </script> 

and following script in test.js:

var external = {     my:'object' }; 

the log show {my:'object'}


Comments

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -