【发布时间】:2015-07-05 18:40:48
【问题描述】:
我有下面的 html 页面,当您在下拉列表中选择一个项目时,它会运行一个函数。 每次我单步执行该函数并到达该行时
$("#ddlRoute").html(procemessage).show();
我收到此错误:未捕获的类型错误:$ 不是函数
你知道这是什么吗?我该如何解决这个问题?
@using (Html.BeginForm())
{
<div id="RowOne-form">
<div class="section1">
<h2>Select a Customer</h2>
<div>
<label for="Branch">Branch:</label>
@Html.DropDownListFor(m => m.SelectedBranch, Model.BranchList, "Select Branch", new { @id = "ddlBranch", @style = "width:200px;", @onchange = "javascript:GetRoute(this.value);" })
</div>
<div>
<label>Route:</label>
<select id="ddlRoute" name="ddlRoute" style="width: 200px"></select>
</div>
</div>
<hr />
<div class="form-Buttons-Sec" style="margin:35px;">
<input id="Save1" type="button" value="Save"/>
<input id="Cancel1" type="button" value="Cancel" />
</div>
}
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
<script language="javascript" type="text/javascript">
function GetRoute(_branchId) {
var procemessage = "<option value='0'> Please wait...</option>";
$("#ddlRoute").html(procemessage).show();
var url = "/Home/GetRouteByBranchId/";
$.ajax({
url: url,
data: { branchId: _branchId },
cache: false,
type: "POST",
success: function (data) {
var markup = "<option value='0'>Select City</option>";
for (var x = 0; x < data.length; x++) {
markup += "<option value=" + data[x].Value + ">" + data[x].Text + "</option>";
}
$("#ddlRoute").html(markup).show();
},
error: function (reponse) {
alert("error : " + reponse);
}
});
}
</script>
【问题讨论】:
-
你没有包括 jQuery... jQuery UI != jQuery
-
我做到了。这是行。
-
此链接包含 jQuery UI,而不是 jQuery...