Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7516557
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T01:10:10+00:00 2026-05-30T01:10:10+00:00

I use the autocomplete function of jQuery UI. $(#search).autocomplete({ minLength: 0, source: ‘source.php’, select:

  • 0

I use the autocomplete function of jQuery UI.

$("#search").autocomplete({
minLength: 0,
source: 'source.php',
select: function( event, ui ) {
    $("#search").val(ui.item.label);
    return false;
},
focus: function(event, ui) {
    $("#search").val(ui.item.label);
    return false;
}

});

I insert multiple elements in the source.php and return them json encoded.

$search[] = array(
   'value' => $id,
   'label' => $name
);
echo json_encode($search);

When I start typing into the autocomplete field a list is shown with the elements of the source.php. But unfortunately with all of them. They are not filtert depending on what I enter in the field.

Is there any special option I have to set when I work with json?

EDIT: Thanks to T.J. Crowder I came up with this solution to let jQuery do the job ; )

$.getJSON('source.php', function(search) {
    $("#search").autocomplete({
    minLength: 0,
    source: search,
    select: function( event, ui ) {
       $("#search").val(ui.item.label);
       return false;
    },
    focus: function(event, ui) {
        $("#search").val(ui.item.label);
        return false;
    }
});
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T01:10:12+00:00Added an answer on May 30, 2026 at 1:10 am

    It’s not obvious from the docs, but when you supply anything as source that will involve running your code (either server- or client-side), the jQuery UI autocompleter expects you to filter the result. In the case of server-side code, you’d use the term parameter it passes to your PHP file. 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 request parameter “term” gets added to that URL. The data itself can be in the same format as the local data described above.

    (It would be good if they actually mentioned filtering there; I’ve logged an issue suggesting that they do. Update: It took them less than three hours to update the docs and close the issue; new docs will be pushed at some point, at least by v1.9. Nice!)

    The autocompleter allows you to supply sources in three ways:

    • Static source array: In this case, the autocompleter does the filtering.

    • Server-side call: In this case, it passes a term argument and you’re expected to use it to filter.

    • Client-side call: In this case, it passes a request object to your client-side code that has a term property; you’re expected to use that to filter.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I use the jQuery Autocomplete plugin to display user info in the search box
Im using jQuery UI autocomplete. When i use a local variable as source it
I'm trying to use the new autocomplete function in jQuery UI, but I'm having
I am trying to use jQuery's fancy autocomplete function but I have a problem
Context I use jQuery UI autocomplete with a remote datasource. The source send data
I use jQuery UI Autocomplete. Part of script is: $(input[data-autocomplete]).each(function () { var availableTags
How can I use the selected item from a jQuery-ui autocomplete in a further
I want to use autocomplete for jQuery in Eclipse. The Aptana Plugin is installed:
I want to use autocomplete (jquery or .net) with force a choice so that
I use jquery.autocomplete , which uses a javascript regexp to highlight substrings in the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.