I can't seem to get my head around this problem.
Those values should then come back and are written to the DOM in an ASP.NET Web Forms Update Panel which does an auto postback to the server. The server then does a lookup in a custom database and returns the nearest 50 or so locations as points to a Google Map which is rendered on postback by passing jQuery document ready an anon function.
Of course, this isn't what happens. Everything does not occur sequentially. (I wouldn't expect it to, I just need to know the correct way to address the issue.)
You just need to nest your synchronous stuff inside any async callback. The key to async programming is remembering that functions in JS are just objects and can be passed around.
So you define all your callbacks upfront, then chain them into one another. The below is by way of example (I assumed your database
lookup was synchronous) so apologies if doesn't make perfect sense, but gives an idea on how to do the async bit.
Put everything inside the
$(document.ready) rather than splitting it up into 2 scripts: