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 8807903
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T02:29:00+00:00 2026-06-14T02:29:00+00:00

Using jQuery 1.7.2 and jQuery UI 1.8.18. If I use local data for the

  • 0

Using jQuery 1.7.2 and jQuery UI 1.8.18. If I use local data for the source attribute, everything works as expected. According to the documentation, a source array can be an array of string values or an array of objects:

Array: An array can be used for local data. There are two supported
formats:

An array of strings: [ "Choice1", "Choice2" ]

An array of objects with label and value properties: [ { label: "Choice1", value:
"value1" }, … ]

Additionally, the source attribute can be a URL that responds with JSON data formatted as shown above:

String: 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 a query
string is added with a term field, which the server-side script should
use for filtering the results. For example, if the source option is
set to "http://example.com" and the user types foo, a GET request
would be made to http://example.com?term=foo. The data itself can be
in the same format as the local data described above.

If my JSON responder returns a simple array of strings, autocomplete works exactly as it should. If, however, my JSON responder returns an array of objects formatted as above, the request is made to the URL but the dropdown list is never populated. The JavaScript console shows no errors.

The autocomplete invocation looks like this:

var source_url = '/json/codes.php?type=globalcode&cid=25';
$('.gcode').autocomplete({
        minLength: 2,
        source: source_url
});

The responder is written in PHP. It is just a stub until I get this problem solved:

header('Content-Type: application/json, charset=UTF-8');
...
if( !$_REQUEST['type'] || !$_REQUEST['cid'] ){
        echo('[]');
        return false;
}
if( $_REQUEST['type'] == 'globalcode' ){
        $cid = sprintf("%d", $_REQUEST['cid']);
        $stub = "[ { label: 'Label for 1234', value: '1234' }, { label: 'Label for 5678', value: '5678' } ]";

        echo( $stub );
        return false;
}

Again, it works with both kinds of arrays when the data is local and it works with an array of string values when the data is remote. When the data is a remote array of objects, the list is never populated and JavaScript throws no errors.

  • 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-06-14T02:29:01+00:00Added an answer on June 14, 2026 at 2:29 am

    You have invalid JSON, this is never logged in the console.
    JSON cannot have single quotes, use double quotes, also use JSONLint to check your JSON.

    This is the valid version of your JSON:

    [
      {
        "label": "Labelfor1234",
        "value": "1234"
      },
      {
        "label": "Labelfor5678",
        "value": "5678"
      }
    ]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im using jQuery UI autocomplete. When i use a local variable as source it
My jQuery code (using ajax) request's data from a local php script (pgiproxy.php). This
I've a code to sort table using Jquery.I use toggle function to alternate clicks,and
I want to use jquery append() using an id as my selector, however the
Using Jquery 1.6.4. I'm attempting to use css to give my app a clue
I have been using Jquery alot lately an was wondering if I should use
We are using jquery to .load() a form into a div We then use
If I'm alreadu using jquery library on site then should i use origional sifr
I am using jquery autocomplete pluguin. Configured to use multiple Values. I set option
I'm alreadu using jquery library on site. What are pros and cons to use

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.