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
Post a Comment