添加一些自动完成代码后出现此错误。在网上搜索后,我确信它与重复的 jQuery 引用有关,但我只引用了一次。
应用程序使用母版页,但相关页面不使用它,因此我在两者中都引用了 jquery。
$(".autosuggest").autocomplete({
source: function(request, response) {
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "CustomerTypes.aspx/GetAutoCompleteData",
data: "{'Customer':'" + document.getElementById('txtCustomerType').value + "'}",
dataType: "json",
success: function(data) {
response(data.d);
},
error: function(result) {
alert("Error");
}
});
}
});
最佳答案
autocomplete()
是jQueryUI library 中的一个方法。 。您需要添加对该以及 jQuery.js 的引用:
<link rel="stylesheet" href="https://code.jquery.com/ui/1.12.0/themes/smoothness/jquery-ui.css" />
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<script src="https://code.jquery.com/ui/1.12.0/jquery-ui.min.js"></script>
关于jquery - 对象不支持属性或方法 'autocomplete',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19928826/