AJAX Cascading with MVC4

后端 未结 2 1345
故里飘歌
故里飘歌 2021-01-16 07:35

I used the below method for doing Async postback using AJAX. This works fine on clicking submit. But i would like to know, is that pos

2条回答
  •  渐次进展
    2021-01-16 08:33

    public JsonResult getCity(string country)
        {
            var temp = (from cntry in db.Table3.OrderBy(s => s.country)
                        where (string.Compare(cntry.country, country) == 0)
                        select cntry.city).ToList();
            return Json(temp, JsonRequestBehavior.AllowGet);
        }
    

    View

    Countries

    State

    @* The following jquery code finds the selected option from country dropdown and then sends an ajax call to the Home/getcity method and finally populate it to the city dropdown *@

提交回复
热议问题