未捕获类型错误:$不是函数 [英] uncaught type error:$ is not a function

查看:586
本文介绍了未捕获类型错误:$不是函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有下面的html页面,当你在下拉菜单中选择一个项目时,它运行一个函数。
每次我通过该函数,我到达行

I have the html page below and when you select an item on the dropdown it runs a function. Each time I step through the function and I get to the line

    $("#ddlRoute").html(procemessage).show();

我得到这个错误:uncaught typeerror:$不是函数

I get this error : uncaught typeerror:$ is not a function

你知道这是什么吗?如何解决这个问题?

Do you know what this is? How do I resolve this?

    @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可能不正确。尝试使用此代替...

It seems the url you are using to obtain your reference to jQuery may be incorrect. Try using this one instead...

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

这篇关于未捕获类型错误:$不是函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆