Javascript jQuery链接下拉列表don´;通过浏览器访问时无法工作
我确实在MVC中创建了一个Web应用程序,其中两个jQuery下拉列表以这种方式链接:第一个下拉列表显示(来自数据库)我所在国家的所有部门(我不住在美国,但……大家好,你们的国家很美),一旦选择了该部门,第二个下拉列表必须显示所有城市(西班牙语中的市政)所选部门的名称 当我在Visual Studio中调试时,一切正常,但当我发布应用程序并通过浏览器访问它时(无论浏览器是chrome、explorer还是firefox),第一个下拉菜单工作正常,但第二个下拉菜单总是发送错误消息,即Javascript jQuery链接下拉列表don´;通过浏览器访问时无法工作,javascript,c#,jquery,wcf,Javascript,C#,Jquery,Wcf,我确实在MVC中创建了一个Web应用程序,其中两个jQuery下拉列表以这种方式链接:第一个下拉列表显示(来自数据库)我所在国家的所有部门(我不住在美国,但……大家好,你们的国家很美),一旦选择了该部门,第二个下拉列表必须显示所有城市(西班牙语中的市政)所选部门的名称 当我在Visual Studio中调试时,一切正常,但当我发布应用程序并通过浏览器访问它时(无论浏览器是chrome、explorer还是firefox),第一个下拉菜单工作正常,但第二个下拉菜单总是发送错误消息,即错误:函数(e
错误:函数(ex)
这些是部门和城市的财产
<div class="form-group">
<div class="col-md-5">
@Html.LabelFor(model => model.dptoEvento, htmlAttributes: new { @class = "control-label" })
<div class="input-group">
<span class="input-group-addon" id="basic-addon1">Seleccione</span>
@Html.DropDownListFor(model => model.dptoEvento, ViewBag.ddlDpto as SelectList, "", new { @class = "form-control", @id = "ddDepartamentos", @title = "especifique departamento en que impartirá el evento", @Value = ViewBag.dptoEvento })
</div>
@Html.ValidationMessageFor(model => model.dptoEvento, "", new { @class = "text-danger" })
</div>
<div class="col-md-5">
@Html.LabelFor(model => model.municipioEvento, htmlAttributes: new { @class = "control-label" })
<div class="input-group">
<span class="input-group-addon" id="basic-addon1">Seleccione</span>
@Html.DropDownListFor(model => model.municipioEvento, ViewBag.ddlMunicipio as SelectList, "", new { @class = "form-control", @id = "ddMunicipios", @title = "especifique municipio en que impartirá el evento"})
</div>
@Html.ValidationMessageFor(model => model.municipioEvento, "", new { @class = "text-danger" })
</div>
</div>
最后是jQuery库
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-datetimepicker/2.5.4/build/jquery.datetimepicker.full.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.css">
<link rel=" stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<link href="@Url.Content("/css/modern-business.css")" rel="stylesheet">
你能告诉我怎么了吗?(我在prekss F12时在控制台上遇到此错误)
编辑:刚刚更改了的url信息url:“/Home/ObtenerMunicipio”
url:'@url.Action(actionName:“ObtenerMunicipio”,
但仍然不起作用controllername:“Home”),谢谢,是的,我刚刚更新了一个404问题,这意味着这里什么都没有。将该链接直接放在浏览器中,看看会发生什么。您可以在url中传递任何变量,如/Home/ObtenerMunicipio?id=123456我确实解决了url“../Home/ObtenerMunicipio”的问题
ProxyGFC.ServiceGFCClient cliente = new ProxyGFC.ServiceGFCClient();
ViewBag.ddlDpto = new SelectList(cliente.PoblarDDLDpto(), "codigoDpto", "departamento");
ViewBag.ddlMunicipio = new SelectList(cliente.PoblarDDLMunicipio(datos.dptoEvento), "codigoMunicipio", "nombreMunicipio");
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-datetimepicker/2.5.4/build/jquery.datetimepicker.full.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.css">
<link rel=" stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<link href="@Url.Content("/css/modern-business.css")" rel="stylesheet">