[英]TypeError: $(…).autocomplete is not a function
I am getting the above error using the following code inside a ASP.NET MVC 我在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 is definitely loaded, and I have tried using a different variable for $ - any ideas what else might be the problem? jQuery肯定已加载,并且我尝试为$使用其他变量-任何想法还有什么问题?
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 当您在本地运行应用程序并包括服务器中的库时,您需要在链接之前编写http://
或https://
,就像在服务器上上传站点时一样,它不是必需的,但在本地上是必需的
<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. 否则下载它们或从本地路径使用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.