I am trying to create a cascading dropdown for City based on the Province using jQuery
but I keep receiving the error:
Failed to load resource: net::ERR_SPDY_PROTOCOL_ERROR
My Javascript is firing.
$(function () {
$('#provinceList').change(function () {
var url = '@Url.Content("~/")' + "Cities/GetCityByProvince";
var ddlSource = "#provinceList";
$.getJSON(url, { provID: $(ddlSource).val() }, function () {
$("#cityList").append("<option value=1> Hi + </option>")
// });
//$("#cityList").html(items);
})
});
});
And the return object from my class is populated correctly
public ActionResult GetCityByProvince(int provID)
{
List<City> cities = new List<City>();
cities = _context.Cities.Where(m => m.ProvinceId == provID).ToList();
cities.Insert(0, new City { ID = 0, CityName = "Please select your nearest city" });
var x = Json(new SelectList(cities, "Id", "CityName"));
return Json(x);
}
However I am still getting this error.