Sending variable to $.getScript

Posted by oshirowanen on Stack Overflow See other posts from Stack Overflow or by oshirowanen
Published on 2012-11-15T10:58:08Z Indexed on 2012/11/15 10:59 UTC
Read the original article Hit count: 413

Filed under:
|
|

Is it possible to send a variable to the script loaded using $.getScript?

At the moment I have:

$.getScript( "js/my_script.js", function() {
// do something here after script has loaded
});

But I want to send a variable to the loaded script. Is this possible, if yes, how?

For example

// 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
});

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about jquery-ajax