I have a Javascript object that I use for global variables, username, userid, etc.. I call it myGlobals. I have a need to load another object via jQuery (application preferences) that I will also need to access globally. For cleanliness, I want it to be a part of myGlobals.
I see posts on how to "merge" the two objects, or add the second one as an array, but that is not exactly what I want. I have this:
var appPref = JSON.parse(xhr.responseText); //this works fine
myGlobals.appPref = appPref; // this does not
I want to be able to do something like this:
alert(myGlobals.appPref.messages.hello);
but I am getting a "myGlobals.appPref: is undefined.
How do I do this? I am using jQuery if there is some magic in there that I could use.