.ajax() Timing Considerations

.ajax() Timing Considerations

I am having some 'timing issues' when using .ajax() in asynchronous mode.  Basically I have two functions:

retrieve_data();
work_on_data();

They are called in this order.

retrieve_data() performs an .ajax() call, and the return data is used to populate a data-structure as a function passed in to the .ajax().success callback method.

The obvious problem is that work_on_data() is being called before the data-structure is being populated, so nothing is built correctly and displayed on the page.

A 'hack' solution would be to put work_on_data() in the success() callback.  However I do not want these two functions to be coupled together as not everytime I retrieve the data i will want to 'work on it'.

What would be a good solution to avoid calling work_on_data() too early, as in this example?

Thanks in advance for your help!