TypeError:$(…).autocomplete不是函数 [英] TypeError: $(…).autocomplete is not a function

查看:99
本文介绍了TypeError:$(…).autocomplete不是函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在ASP.NET MVC中使用以下代码遇到上述错误

I am getting the above error using the following code inside a ASP.NET MVC

<script type="text/javascript" >
$(document).ready(function () {
    $("#Name").autocomplete({
        source: function (request, response) {
            $.ajax({
                url: "/Home/Index",
                type: "POST",
                dataType: "json",
                data: { Prefix: request.term },
                success: function (data) {
                    response($.map(data, function (item) {
                        return { label: item.Name, value: item.Name };
                    })
                }
            })
        },
        messages: {
            noResults: "", results: ""
        }
    });
})

Jquery肯定已加载,并且我尝试为$使用其他变量-任何想法还有什么问题?

Jquery is definitely loaded, and I have tried using a different variable for $ - any ideas what else might be the problem?

推荐答案

在本地运行应用程序并包括服务器中的库时,您需要在链接之前写http://https://,就像在站点上上传站点时一样.服务器不是必需的,但在本地是必需的

When you run the application on local and including libraries from server you need to write http:// or https:// before the link as when you upload the site on server its not necessary but its required on local

<script src="http://code.jquery.com/jquery-1.10.2.js"></script>
<script src="http://code.jquery.com/ui/1.11.4/jquery-ui.js"></script>

或者下载它们或从本地路径使用.

Or else download them or use from local path.

这篇关于TypeError:$(…).autocomplete不是函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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