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

  • SEARCH
  • Home
  • 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 9194373
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T21:23:50+00:00 2026-06-17T21:23:50+00:00

another question about jQuery autocomplete with wich i’m having problems despite the numerous resources

  • 0

another question about jQuery autocomplete with wich i’m having problems despite the numerous resources on this forum or on jQuery docs.

I’m having a hard time mapping response data from a PHP script with jQuery UI. Here is the code:

$("#shared-with").autocomplete({
  source: function(request, response) {

    $.ajax({
      type: 'get',
      url: 'ajax/search.php',
      data: { term: request.term },
      success: function(data){

           // alert(data);
           response($.map(data, function(c) {
             return {
                 label: c.name,
                 value: c.nametag
             }
           }));

     }
   });
 }
});

My problem is that the response/map function is not properly understood by jQuery autocomplete although the data that is sent back from search.php looks like:

echo json_encode(
     array('name' => 'Bill', 'nametag' => 'Big Bill'),
     array('name' => 'Fred', 'nametag' => 'Small Fred'),
);

PS: when i alert “data” in javascript popup show me a valid javascript array/object…
PS: “#shared-with” is just the textarea

Any idea ? Thanks in advance.

  • 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-17T21:23:51+00:00Added an answer on June 17, 2026 at 9:23 pm

    I found that the data was in fact return as a string from my PHP search page.

    All i needed to do was reconvert the string into an JS array:

    data = $.parseJSON(data);
    
    response($.map(data, function(c) {
                 return {
                     label: c.name,
                     value: c.nametag
                 }
    }));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I made another question about two weeks ago with having trouble with the Circle
I know there is another question about this here but this just isn't working
I was just reading another question about jQuery's synchronous ajax call, and I got
I found another similar question about this with a solution but it didn't work
I asked this morning a question about a jQuery code that's not working (which
I've asked about this very example in another question: Fill in a form with
ok, yet another jquery selector nightmare for me ! I've read about 20 questions
Answering another question about how const string data was stored in an executable a
By refering to Another Question About ActiveX freezes IE , I wrote an Active
I've recently made another question about connecting to MS-ACCESS database with .NET in C#

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.