Javascript,jquery错误TypeError:$(...)。autocomplete不是函数

时间:2022-11-05 12:11:39

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 ?

我猜我已经做了一些错误的脚本?

3 个解决方案

#1


5  

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>

#2


2  

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>

#3


-1  

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 :)

谢谢所有帮助:)

#1


5  

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>

#2


2  

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>

#3


-1  

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 :)

谢谢所有帮助:)