【问题标题】:uncaught type error:$ is not a function未捕获的类型错误:$ 不是函数
【发布时间】: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...

标签: jquery html c#-4.0


【解决方案1】:

您用来获取对 jQuery 的引用的 url 似乎不正确。尝试改用这个...

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>

【讨论】:

  • 您没有发送任何网址。谢谢
猜你喜欢
  • 1970-01-01
  • 2022-11-19
  • 1970-01-01
  • 2019-06-06
  • 2019-05-24
  • 2021-12-15
  • 2019-10-26
  • 2016-06-27
  • 2021-12-19
相关资源
最近更新 更多