Javascript, jquery 错误 TypeError: $(...).autocomplete is not a function
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/27105163/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Javascript, jquery error TypeError: $(...).autocomplete is not a function
提问by rekoDolph
I have looked around at questions similar to the above and none of them have helped.
我环顾了与上述类似的问题,但没有一个有帮助。
Here are my scripts
这是我的脚本
<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>
<script type="text/javascript" src="network.json"></script>
<script type='text/javascript' src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"> </script>
<link type="text/css" href="http://code.jquery.com/ui/1.9.1/themes/smoothness/jquery-ui.css" rel="stylesheet" />
<body>
<link href="ajs_network1.css" rel="stylesheet" type="text/css" />
<script src="ajs_network1.js" type="text/javascript"></script>
</body>
Here is the function trying to call JQuery
这是试图调用 JQuery 的函数
$(function () {
$("#search").autocomplete({
source: optArray
});
});
For some reason its bringing up the error
出于某种原因,它提出了错误
TypeError: $(...).autocomplete is not a function.
I am guessing ive done something wrong with the scripts ?
我猜我的脚本做错了什么?
采纳答案by rekoDolph
The links were correct i was using. But because i was retrieving links online i didnt put in http at the beginning. So the links would now be :
我使用的链接是正确的。但是因为我是在网上检索链接,所以一开始我没有输入http。所以链接现在是:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/themes/smoothness/jquery-ui.css" />
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/jquery-ui.min.js"></script>??
Also, there were hidden characters for some reason when i copied the link over so the link wasnt working. When working with this make sure your browser is retrieving the links. FireBug help me with this. Click 'net' and it will tell you what scripts the browser is importing.
此外,由于某种原因,当我复制链接时存在隐藏字符,因此链接无法正常工作。使用它时,请确保您的浏览器正在检索链接。FireBug 帮我解决这个问题。单击“net”,它会告诉您浏览器正在导入哪些脚本。
Thankyou to all that helped :)
感谢所有帮助:)
回答by Saineshwar
by just adding this link reference my issue was resolved
只需添加此链接参考,我的问题就解决了
<script async src="//code.jquery.com/ui/1.10.1/jquery-ui.min.js"></script>
回答by Ramzan Zafar
Try adding those links into your code as you are missing those
尝试将这些链接添加到您的代码中,因为您缺少这些链接
<link rel="stylesheet" href="//ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/themes/smoothness/jquery-ui.css" />
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/jquery-ui.min.js"></script>