1

The first implementation works properly. The second provides a dropdown list, but it is not filtered as you type.

    $( "#tags" ).autocomplete({
        source: availableTags
    });
    $( "#tags1" ).autocomplete({
        source: "http://nwx1/mysql/useractivitytxn/f_UsersList.php"
    });

...

<div class="ui-widget">
    <label for="tags">Tags: </label>
    <input id="tags">
    <label for="tags1">Tags1: </label>
    <input id="tags1">
    <label for="tags2">Tags2: </label>
    <input id="tags2">
</div>

var availableTags = [ "ActionScript", "AppleScript", "Asp", "BASIC", "C", "C++", "Clojure", "COBOL", "ColdFusion", "Erlang", "Fortran", "Groovy", "Haskell", "Java", "JavaScript", "Lisp", "Perl", "PHP", "Python", "Ruby", "Scala", "Scheme" ];

the return value from the web service: ["ActionScript","AppleScript","Asp","BASIC","C","C++","Clojure","COBOL","ColdFusion","Erlang","Fortran","Groovy","Haskell","Java","JavaScript","Lisp","Perl","PHP","Python","Ruby","Scala","Scheme"]

                    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript"></script> 
        <script src="http://code.jquery.com/ui/1.8.22/jquery-ui.min.js" type="text/javascript"></script>
        <script src="http://jquery-ui.googlecode.com/svn/tags/latest/external/jquery.bgiframe-2.1.2.js" type="text/javascript"></script>    
3
  • I even get the whole drop down if I type '3'. Commented Aug 7, 2012 at 16:37
  • Selecting from the whole list still places the value in the input box. Commented Aug 7, 2012 at 16:48
  • This could probably be deleted since it was answered here: stackoverflow.com/questions/9349370/… I had an old set of the docs. Commented Aug 7, 2012 at 19:41

1 Answer 1

1

From the docs:

When a String is used, the Autocomplete plugin expects that string to point to a URL resource that will return JSON data. It can be on the same host or on a different one (must provide JSONP). The Autocomplete plugin does not filter the results, instead the request parameter "term" gets added to the URL, which the server-side script should use for filtering the results.

Autocomplete can have one of three source types: an array with local data, a string, specifying a URL, or a callback. Your first example uses an array while your second uses a string, specifying a URL, therefore you need to do the filtering and return the filtered result set.

Sign up to request clarification or add additional context in comments.

2 Comments

Hmm, OK. It would be more responsive to put the result in a local array and then let autocomplete filter. Thanks.
And that's not very nice if you don't have control of the server side.

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.