Yeah you don't get synchronous calls in javascript I'm afraid. You should look into jquery deferreds (or async.js) if you need to resolve a race condition.