$('#ProvinceId').change(function () {
$('#DistrictId').attr('disabled', true);
$('#dispreloader').fadeIn(200);
$.getJSON('@Url.Action("GetDistricts/")' + $('#ProvinceId').val(), function (data) {
var items = "";
items += "<option value='' disabled selected>Seçim Yapın..</option>";
$.each(data, function (i, item) {
items += "<option value='" + item.Id + "'>" + (item.Name) + "</option>";
});
$("#DistrictId").html(items);
$('#DistrictId').removeAttr('disabled');
$('#dispreloader').fadeOut(200);
});
});Controller
public ActionResult GetDistricts(int Id)
{
#if DEBUG
System.Threading.Thread.Sleep(2000);
#endif
return Json(DbContext.Districts.Where(p => p.ProvinceId == Id).Select(p => new { Id = p.Id, Name = p.Name }), JsonRequestBehavior.AllowGet);
}kendine göre düzenle