One of the options is to to make Ajax request to action which will return your list items
public virtual JsonResult GetCountryStates()
{
return Json(
new
{
new List<SelectListItem>() {YOUR ITEMS HERE}
});
}
Then in your Ajax callback body put code like that
function (data) {
//var selValue;
data = $.map(data, function (item, a) {
if (item.Selected) {
selValue = item.Value;
}
return "<option value=\"" + item.Value + "\" " + (item.Selected ? "selected" : "") + ">" + item.Text + "</option>";
});
$('statesSelect').html(data.join(""));
$('statesSelect').val(selValue);
},
0
solved how to fill 2nd combobox with asp.net mvc ajax