1

So I am dealing with Jquery auto complete.

I include jquery and auto complete jquery stuff.

    <script src="../../jquery/jquery.js"></script>
    <script src="../../jquery/jquery.autocomplete.js"></script>

<script>
$(document).ready(function() {
    var townList = ["London","Manchester"]; //establish user town list
    $("input#townSearcher").autocomplete({source:townList});
}
    </script>

<input type="text" id="townSearcher" />

The AutoComplete does not work when i put Lon in or Manc for example, what am I missing in this simple example?

0

2 Answers 2

3

you need to give it an object

$("input#townSearcher").autocomplete({source:townList});

working demo

here is the autocomplete documentation

edit

you may want to try using cdn

 <script src="http://code.jquery.com/jquery-1.5.2.min.js"></script>
 <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.13/jquery-ui.min.js"></script>
Sign up to request clarification or add additional context in comments.

1 Comment

i have just attempted this, i find it odd how it works on your example and (nw i have edited my code) still does not work in my page.. there are 0 errors, 0 warnings and i do not think anything else is breaking it on the page. :/
2

Make sure the DOM is loaded. You need to wrap your jquery in the onload event.

$(function() { 
  $("input#townSearcher").autocomplete(townList); 
});

Here is a working jsfiddle:

Here

3 Comments

@mcgrailm I'm not for sure what you are seeing, but it works fine. I don't have any CSS, but the autocomplete works just fine. Type an 'L' or an 'M' and it will show the results.
I get error in ff4 say 'Error: $("input#townSearcher").autocomplete is not a function Source File: fiddle.jshell.net/keroger2k/AftpL/1/show Line: 25"
@mcgrailm you were right. the autocomplete src file i was linking to was getting a 403 forbidden. Mine worked fine in chrome though. Thanks for the update.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.