Hi, i have an asp.net mvc 2 application, and have some jquery that defines behaviour of two dropdownlists. When one changes, the other is populated with filtered data. After much furor, i have the jquery working, confirmed by firebug debugging, but my dropdownlist is not refreshing. This is the jquery
<script type="text/javascript">
$(function () {
$('#cid').change(function () {
var coid = $(this).val();
$.post("/TimeTracking/FilterFieldOffices", { companyId: coid }, function (data) {
$("#foid").loadSelect(data);
});
});
});
$(function () {
$.fn.loadSelect = function (data) {
return this.each(function () {
this.options.length = 0;
$.each(data, function (index, itemData) {
var option = new Option(itemData.Text, itemData.Value);
this.add(option);
});
});
};
});
</script>
And here is my controller action
public ActionResult FilterFieldOffices(int companyId = 0)
{
IList<FieldOffice> list = _fodp.GetFieldOfficesForCompany(companyId);
var returnList = new SelectList(list, "Id", "FacilityName");
return Json(returnList);
}
So, i know that dropdownlist is being filled with the correct data, but the dropdownlist on the view page is not refreshing. I have limited knowledge with JQuery, so if im missing something n00b like be gentle.