Set Selectbox value after refresh with Jquery / Javascript?
<p>I'm have a problem with this code not working when it probably should be:</p>

<pre><code>&lt;script language = "javascript"&gt;
$(document).ready(function() {

$('#dept').change(
        function() {

            var datas = $(this).val();
            $.cookie("deptdata", datas);
            var urlDept = 'catch.cfm?dept=' + datas;
            $.ajax({
            type: 'post',
            url: urlDept,
            success: function(){
                 window.location.replace('');
                 var datasR = $.cookie("deptdata");
                 $("select#dept").val(datasR);
            }
             });
}); 

});

&lt;/script&gt;
</code></pre>

<p>I have these included:</p>

<pre><code>&lt;script type="text/javascript" src="js/jquery-1.4.2.min.js"&gt;&lt;/script&gt;
&lt;script type="text/javascript" src="js/jquery-ui-1.8.2.custom.min.js"&gt;&lt;/script&gt;
&lt;script type="text/javascript" src="js/cookie.js"&gt;&lt;/script&gt;
&lt;script type="text/javascript" src="a_scripts.js"&gt;&lt;/script&gt;
</code></pre>

<p>Form:</p>

<pre><code>&lt;form&gt;
    &lt;select name="DeptCode" id = "dept"&gt;
    &lt;option value="NONE"&gt;Choose a Department
    &lt;cfoutput query="getDepartments"&gt;
    &lt;option value="#DeptCode#"&gt;#DeptName#&lt;/option&gt;
    &lt;/cfoutput&gt;
    &lt;/select&gt;
    &lt;/form&gt;
&lt;cfoutput&gt;#session.deptcode#&lt;/cfoutput&gt;
</code></pre>

<p>What should be happening is: when a department is selected the page changes the session value via ajax (this works) to the one selected. However, I have to refresh the page for the query to work for another part of the page. So I wanted to cache the value of the select and reassign it to be selected after the page refreshes. (So it keeps the item selected).</p>
