我想使用jquery ui的自动完成功能,但我有一个问题 .
我使用谷歌的外部库:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
< script type = "text/javascript"
src = "https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js" > < /script>
我的自动完成脚本
$("#search").autocomplete({
source: 'autocomplete-search.php',
});
我有这个错误:
jQuery.Deferred异常:$(...) . autocomplete不是函数TypeError:$(...) . autocomplete不是HTMLDocument中的函数 . (http://localhost/sitename/script.js:382:16)j(https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js:2:29948) at k(https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js:2:3062)> undefined
1 回答
在jquery-ui包含之前,您还需要将JQuery本身包含在项目中 . 为了能够解析这个,
,JQuery本身是必需的 . 在您的其他脚本之前尝试从谷歌中包含此内容 .