标签:wget href 二级联动 城市列表 index name key null plain
二级联动:View: <script type="text/javascript"> $(function () { $("#drpProvince").change(function () { $("#drpCity").get(0).options.length = 0; //清空 $.getJSON("/Persons/GetCities/" + $(this).val(), null , function (data) { $.each(data, function (i, item) { $("<option></option>").val(item["ID"]).text(item["CityName"]).appendTo($("#drpCity")); }); }); }); });</script>@Html.DropDownList("drpProvince",null,"请选择")@Html.DropDownList("drpCity", null,"请选择")Action: public ActionResult Create() { List<Provinces> list = db.Provices.ToList(); ViewData["drpProvince"] = new SelectList(list, "ID", "ProvinceName"); ViewData["drpCity"] = new List<SelectListItem>(); return View(); } //返回城市列表 public ActionResult GetCities(int? id) { List<Cities> list = db.Cities.Where(q => q.ProvincesID == id).ToList(); if (Request.IsAjaxRequest()) { return Json(list, JsonRequestBehavior.AllowGet); } else { return View(""); } } 标签:wget href 二级联动 城市列表 index name key null plain
原文地址:https://www.cnblogs.com/wangdongying/p/11378723.html