views:

19

answers:

1

I declared global variable in js file which is filled after jquery.ajax call. Everything works fine when I put breakpoint to see if the global variable has its value with Firebug, I can see it, no problem. But when I remove breakpoint and try again, error with variable 'undefined' shows. I also tried to put result into hidden field and then retreive its value later. Same error.

I don't know what is happening? With breakpoint set in Firebug it works fine, without it, shows 'undefined' error.

P.S. No postbacks are made in these processes.

A: 

The symptoms suggest it is a timing issue: when you set the breakpoint, the ajax call has time to 'return', but without it, you are executing code that depends on the ajax call, but it has not returned yet.

That's all I can think of, without having seen the code..

Jochem
Good thinking Jochem, thank You! Maybe after putting setTimeout() before checking variable will help. I'll try to do that.
Ogi
After setting setTimeout() everything works fine. Thanx Jochem!
Ogi