This is a classic mistake when using asynchronous programming. You can no longer think of a single stepwise order of execution, call function a(), then b(), then c(). When using any form of ajax call, it is usually asynchronous. That means that calling the function only starts it's execution.
It will then run in the background and the rest of your javascript will keep running and finish. Then, sometime later, the ajax call will complete and it will call it's success function. ONLY from that success function or any other code that you call from the success function can you actually use the results of your ajax call. So, what you essentially have to do is start the ajax call and then your javascript code finishes for the moment. You then write a success function which will pick up execution of the rest of what you need to do when the ajax call completes. At that point, you have your JSON data and you can do with it what you want. You can take that data and call other functions, passing it along to them so they can operate on it.
So, kick of your second step of execution from the success handler. Whatever you need to do with the retrieved data should start in the success handler.
So, if the flow of execution you wanted to do was this:
a();
b();
getJSONdata();
c();
d();
You would have to structure it like this:
a();
b();
getJSONdata("xxx", function(data) {
c(data);
d();
})
function c(myData) {
// do something with the passed in data
}
where c() and d() are happening in the success function from retrieving the JSON data and they are called ONLY after the data is available.