是否可以将变量发送到使用加载的脚本$.getScript
?
目前我有:
$.getScript( "js/my_script.js", function() {
// do something here after script has loaded
});
但我想向加载的脚本发送一个变量。这可能吗,如果可以,怎么做?
例如
// this is a variable set outside of the script loaded via `$.getScript`
var my_variable = 1
// how do I get that variable sent to `my_script.js`
$.getScript( "my_script.js", function() {
// do something here after script has loaded
});