[jQuery] How to Clean Up Asynch Code

[jQuery] How to Clean Up Asynch Code


// what's a clean way to populate a list asynchronously and then
compare the number of items in the list to a count?
$(function() {
    populateList();    // this is an asynch call using $get - so the next
line will not work.
    hideDivWhenListCountMatchAccountCount();
});
Should I change populateList to take a function and then pass in
hideDivWhenListCountMatchAccountCount() as my callback which
populateList will call when done?
I do not want to change the populateList to act as a synchronous call.
Thanks.