Waiting for AJAX request to finish?
<p>I have a problem that is confusing me at the moment. I am using ajax to get some ID's from a website. Once it's complete I want to store the ID's in a variable for further processing. I have my code laid out like this:</p>

<pre><code>var ids;

function get_ids() { ... Get the ID's from the site and store them in the global variable ids ... }

get_ids();
alert(ids.length);
</code></pre>

<p>As you can see ids will always be 0 because the script will continue to run before the ajax request in get_ids has had a chance to respond.</p>

<p>What's the best way to what I'm trying to do? I want to wait until get_ids has finished.</p>
