3

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 ?

8
  • 3
    You need to add jQuery UI library <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> Commented Nov 24, 2014 at 12:43
  • 1
    Load jquery at the top of the head tag Commented Nov 24, 2014 at 12:44
  • 1
    Agreed with Satpal autocomplete is a jQueryUI's plugin so include this library after jQuery lib. Commented Nov 24, 2014 at 12:45
  • add this <script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/jquery-ui.min.js"></script> Commented Nov 24, 2014 at 12:45
  • @Satpal ReferenceError: $ is not defined. I get this error ? Commented Nov 24, 2014 at 12:49

3 Answers 3

6

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>
Sign up to request clarification or add additional context in comments.

Comments

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>

Comments

0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.