Global variables won't change unless more time is given
I'm trying to run a program that gets a global variable from one script
and returns it in the next. I'm using this method to do it.
When I attempt to get the global variable for my next function, it will
only return if I first run an alert (If I include the variable in the
alert, it returns null). I suspect it's because it needs more time to
write the variable in the previous function but the first js file is
$(document).ready and the next is $(window).load which should run after
all ready() calls are made. Here's my relevant code for the second
function:
alert(window.userid); //returns null
alert(window.userid); //returns value if previous alert is there
alert(getMessages(window.userid)); //runs properly if the alert(s) are
included
No comments:
Post a Comment