Alert says true because evalJson is not done processing JSON data yet (21kb gzipped). I need to wait somehow for it to finish before using that data - exactly what I'd do with DoEvents in a while loop.

4 Answers
4

There is no equivalent to DoEvents, but you can put the code that depends on your JSON data into a function and call it from the AJAX callback. You can also use the $.getJSON method so you don't have to eval the JSON yourself.

Alternatively, jQuery offers a way to make AJAX requests synchronous (i.e. they halt code execution until the response comes back). You can use $.ajaxSetup({ async: false }); or you can call the $.ajax method directly and pass async:false in the options object.

The only thing similar to doEvents in javascript is setTimeout().
the First argument should be a string with the Code you want to execute after the "system events" are done, and the second argument is the number of milisecs to wait...
It's complicated but that is the only solution I know.