There are a couple solutions. The easiest is to put the code inside the getJSON callback function.
lat = data.lat;
lon = data.lon;
* put rest of code that needs lat and lon here