[jQuery] getJSON timing problem (probably a simple newbie problem)

[jQuery] getJSON timing problem (probably a simple newbie problem)


Hi -
I have a simple json file which contains a list of key/path pairs, the
idea is that I will use this to update the links in a nav menu.
In order to do this, I am using getJSON to load and parse the data,
like so:
var pathAssoc = new Array();
var pathVar = null;
function getPathData(){
    $.getJSON("js/paths.js", function(data){ //gets the json object
            //alert(data.paths[1].name);
            //pathArray = data.paths; //creates an array out of our returned
data
            for( var i in data.paths){
                var name = data.paths[i].name;
                var path = data.paths[i].path;
                pathAssoc[name]=path;
            }
            if((page!="")&&(path!="")){
                restoreLocation();
            }
        });
}
My problem is that since it's an asynchronous request, other functions
are trying to access pathAssoc before it is ready. What event should I
be using/listening for in order to make sure pathAssoc is populated
before continuing?
Current dependent functions:
function getPagePath(name){
    pathVar = pathAssoc[name];
    }
So if I call getPagePath() before getPathData() is finished,
everything (predictably) breaks...