Reputation: 1306
I want to set a global variable for right now. I know this is supposed to be a bad thing but when I get this functionality hammered down and a little better with javascript in general, I'll come back to this piece of code and refactor it.
I'm using an ajax call and need the return server value to be stored in a global var. So, if I had: var = MyglobalVar = 'varFromMyServer';
, how exactly do I set this up so I can access it from wherever I want in my script?
Upvotes: 0
Views: 66
Reputation: 9884
window is a global container for browsers.
window.myGlobalVar = 'varFromMyServer';
Upvotes: 2