Skip to content Skip to sidebar Skip to footer

Can't Get Global Variable

Here is the window: so now, when I scroll down (the children appear in the same fashion as displayed above, all way long), I see what I want: but I just fail to access it. Why? Her

Solution 1:

You are running update_match too early.

It seems that while you are running the update_match, the global variables aren't defined yet. They are created later. But because console.log, does not echo out a snapshot of the window object at that time, it shows the global variables, because at the end of your script they got created and console.log shows the "finished" window Object.

To solve your issue, run the update_match later, either after the document is ready or using the setTimeout function with a reasonable delay:

setTimeout(function(){ update_match(); }, 500);

To run the function after the document is ready, take look at this post:

jQuery Mobile: document ready vs page events

You could do it by:

$(document).ready(function() { 

update_match();

});

Post a Comment for "Can't Get Global Variable"