rekoDolph
rekoDolph

Reputation: 823

Javascript, jquery error TypeError: $(...).autocomplete is not a function

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

$(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 ?

Upvotes: 3

Views: 20945

Answers (3)

Saineshwar Bageri - MVP
Saineshwar Bageri - MVP

Reputation: 4031

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>

Upvotes: 6

rekoDolph
rekoDolph

Reputation: 823

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 :

<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.

Thankyou to all that helped :)

Upvotes: 0

Ramzan Zafar
Ramzan Zafar

Reputation: 1600

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>

Upvotes: 2

Related Questions