jQuery wait for all select options to load
<p>I have a select box object and an ajax function is called OnChange using the selected value as an input.  I also want to call the the same function when the select box is first loaded.  I use jQuery .load, but the ajax function is called before any of the options are loaded and the input to my ajax function is undefined.  Does anyone know how to get jQuery to wait for all the options to load before calling the function?</p>

<p>Thanks.</p>

<p><strong>Edit - Adding Code</strong>
I have found that a <code>setTimeout()</code> works pretty well to delay the function.  However, I get nervous using <code>setTimeout()</code> because if the page loads slower than usual, it won't work.  I tried replacing the timeout with <code>$(document).ready</code> as you suggested, but the function was still called before an option was selected and the input was undefined.  </p>

<p>Here's the code:</p>

<pre><code>&lt;script type="text/JavaScript"&gt;    
    setTimeout('AjaxFunction($("#SelectID option:selected").val()));', 400);
&lt;/script&gt;

&lt;select id="SelectID" name="SelectName" onchange="AjaxFunction(this.value);"&gt;
&lt;option value='Inland Empire'&gt;Inland Empire&lt;/option&gt;
&lt;option value='San Bernardino'&gt;San Bernardino&lt;/option&gt;  
&lt;option value='Riverside'&gt;Riverside&lt;/option&gt;
&lt;option value='California'&gt;California&lt;/option&gt;  
&lt;/select&gt;
</code></pre>
