C# 我的javascript代码不工作(调试器未进入get方法)

C# 我的javascript代码不工作(调试器未进入get方法),c#,jquery,html,C#,Jquery,Html,@{ 标题=索引; 布局=空; } 在这里输入代码 使用制度; 使用System.Collections.Generic; 使用System.Linq; 使用System.Web; 使用System.Web.Mvc 使用MVCDropdownlist.Dal 命名空间MVCDropdownlist.Controllers { 公共类DropdownTestController:控制器 { // //获取/下拉测试/ harshalEntities ctx = new Dal.harsha

@{ 标题=索引; 布局=空; }

在这里输入代码

使用制度; 使用System.Collections.Generic; 使用System.Linq; 使用System.Web; 使用System.Web.Mvc

使用MVCDropdownlist.Dal

命名空间MVCDropdownlist.Controllers { 公共类DropdownTestController:控制器 { // //获取/下拉测试/

    harshalEntities ctx = new Dal.harshalEntities();



    public ActionResult Index()
    {
        ViewBag.ddlcountry = CountryBind();
        return View();

    }

    //code for bind Country Name...........................
    public List<SelectListItem> CountryBind()
    {
        List<SelectListItem> li = new List<SelectListItem>();
        foreach (var v in ctx.Countries)
        {
            li.Add(new SelectListItem { Text = v.CountryName, Value = v.CountryId.ToString() });
        }

        //ViewBag.ddlcountry = li;
        //return View();
        return li;

    }

    //code for bind State Name...........................
    public JsonResult StateBind(string country)
    {

        int id = Convert.ToInt32(country);
        var v = ctx.States.Where(m => m.CountryId == id).Select(m => new { Text = m.StateName, Value = m.StateId });
        return Json(v, JsonRequestBehavior.AllowGet);

    }

    //code for bind City Name...........................
    public JsonResult CityBind(string state)
    {

        int id = Convert.ToInt32(state);
        var v = ctx.Cities.Where(m => m.StateId == id).Select(m => new { Text = m.CityName, Value = m.CityId });
        return Json(v, JsonRequestBehavior.AllowGet);

    }
}
}

我的函数不在get方法中


由于这是一个AJAX get,我建议您可以进行一些客户端调试-在web浏览器中点击F12并与应用程序交互,并注意网络选项卡中的更改,包括服务器错误。Firefox中的Firebug插件在这些情况下非常方便。我使用了Firebug,但没有得到什么问题…为什么选择c后状态下拉列表没有填充国家
    harshalEntities ctx = new Dal.harshalEntities();



    public ActionResult Index()
    {
        ViewBag.ddlcountry = CountryBind();
        return View();

    }

    //code for bind Country Name...........................
    public List<SelectListItem> CountryBind()
    {
        List<SelectListItem> li = new List<SelectListItem>();
        foreach (var v in ctx.Countries)
        {
            li.Add(new SelectListItem { Text = v.CountryName, Value = v.CountryId.ToString() });
        }

        //ViewBag.ddlcountry = li;
        //return View();
        return li;

    }

    //code for bind State Name...........................
    public JsonResult StateBind(string country)
    {

        int id = Convert.ToInt32(country);
        var v = ctx.States.Where(m => m.CountryId == id).Select(m => new { Text = m.StateName, Value = m.StateId });
        return Json(v, JsonRequestBehavior.AllowGet);

    }

    //code for bind City Name...........................
    public JsonResult CityBind(string state)
    {

        int id = Convert.ToInt32(state);
        var v = ctx.Cities.Where(m => m.StateId == id).Select(m => new { Text = m.CityName, Value = m.CityId });
        return Json(v, JsonRequestBehavior.AllowGet);

    }
}