jQuery global variable with getScript -
This object is decalred in foo.js, and has been modified in bar.js. And when I getScript, I tried to get results. foo.js P> / * // It works fine, but I want to decalre it inside jQuery var myObject = {str: "hello world", num: "123"}; * / $ (Function () {// This makes my object global variable y myObject = {str: "Hello World", num: "123"}; Warning (myObject.str + "+ myObject.num); $ ; .getScript ("bar.js", function () {warning (myObject.str + "+ myObject.num);});}); bar.js $ (function () {myObject = {str: "new string", number: " 999 "};}); Since you have declared a variable within a function, it is local for functions . What you can do is declare the variable out, but assign values inside jQuery's ready handler foo.js / * // This works fine, but I want to decalre it within jQuery var myObject = {str: "hello world", num: "123"}; * / Var myObject; ...