Jani Tarvainen schrieb:
> Hi,
>
> Just wondering whether it's possible to get the $.getJSON -generated  
> object into local scope? Something along the lines of this:
>
> $(document).ready(function(){
>
>       createObject();
>       appendObject();
>
> });
>
> function createObject(){
>       $.getJSON('animal.js',function(json){
>               animal = json;
>       });
> }
>
> function appendObject(){
>       $("body").append(animal.type);
> }
>   
$.getJSON is asynchronous, there your appendObject() is executed before 
the JSON is available. The easiest solution would be to call 
appendObject from within the callback for getJSON.

-- 
Jörn Zaefferer

http://bassistance.de


_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

Reply via email to