because you are updating i asyncronously it will be overwritten asynconously.
what you could do is add your "purged" data to an array, and read that array elsewhere in a loop. > Date: Mon, 30 Mar 2009 07:20:21 -0700 > Subject: [jQuery] Re: How to access variable outside function > From: iceange...@gmail.com > To: jquery-en@googlegroups.com > > > can i do this at all? i think maybe becos getJSON will be async, i > wont be able to do this? > > btw, background is i am doing some validation. within this validation > i need to get some value from server > > so i did > > function validate() { > var validated = true; > > // some validation > ... > > // get value from server > $.getJSON("url", function(json) { > if (...) { > validated = false; > } > }); > } > > On Mar 30, 10:09 pm, iceangel89 <iceange...@gmail.com> wrote: > > i sometimes do something like > > > > var i; > > $.getJSON("url", function (json) { > > // update i > > i = json.var; > > > > }); > > > > how can i access the updated i outside the function(json)...? _________________________________________________________________ View your Twitter and Flickr updates from one place – Learn more! http://clk.atdmt.com/UKM/go/137984870/direct/01/