I have an asp.net mvc site and i want to call the server when i change a dropdown list. my code hits the server controller action but i never get the callback. Is there any gotcha that i am missing here?
Here is my controller action:
public ActionResult LoadTeamsandApplications(int id)
{
WorkstreamRoadmapViewModel vm = new WorkstreamRoadmapViewModel();
vm.Applications = GetAppList(id, 0);
vm.Teams = GetTeamList(id, 0);
JsonResult result = Json(vm);
return result;
}
NOTE: that GetAppList() and GetTeamList() both return
List<SelectListItem>
Here is my jquery code:
$("#filter").change(function(e) {
var filter= $("#filter").val();
var loadURL = "/List/LoadTeamsandApplications/" + filter;
$.post(loadURL , function(data) {
var items = "<option selected></option>";
$.each(data.Teams, function(i, item) {
items += "<option value='" + item.Value + "'>" + item.Text + "</option>";
});
$("#teamFilter").html(items);
var items1 = "<option selected></option>";
$.each(data.Applications, function(i, items1) {
items1 += "<option value='" + item1.Value + "'>" + item1.Text + "</option>";
});
$("#applicationFilter").html(items);
}, "json");
});
EDIT
i added this code:
$(document).ajaxError(function(e, xhr, settings, exception) {
alert('error in: ' + settings.url + ' \\n' + 'error:\\n' + exception);
});
but all i got back was "Error Undefined"