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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T17:04:58+00:00 2026-06-01T17:04:58+00:00

I have a feeling there is a simple answer to this, but I am

  • 0

I have a feeling there is a simple answer to this, but I am having a problem when returning my JSON data to the JQuery UI Autocomplete function. I am using the ‘label’ and ‘value’ fields so I can store an id field. The problem is I am unable to parse the values in the object once they are passed back to the JQuery function.

in ASP.NET C#, I have an object:

public class AutoCompleteItem
{
    public string label { get; set; }
    public string value { get; set; }
}

and setting them into a list, formatting as JSON and then returning:

List<AutoCompleteItem> autoCompleteItems = new List<AutoCompleteItem>();
// Loop through data, add objects to list
var oSerializer = new JavaScriptSerializer();
string sJSON = oSerializer.Serialize(autoCompleteItems);
return sJSON;

JSON data after being passed to JQuery:

"[{"label":"Steve","value":"ID4545"},{"label":"Joe","value":"ID1212"},{"label":"Rick","value":"ID6767"}]"

and this is the function i am using to try and get the data from the JSON:

success: function (data) {
      response($.map(data.d, function (item) {
          return {
              label: item.label,
              value: item.value
          }
                                }));
},

I noticed that before I used the ‘label’, ‘value’ format, I had it working with just an IList string. The data passed did not have quotes on the outside, whereas my original example does

["Steve", "Joe", "Rick"]

I don’t know if this is related to the problem or not, but I have tried a number of things to no avail. Any help is appreciated!

  • 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-01T17:05:00+00:00Added an answer on June 1, 2026 at 5:05 pm

    There’s no .d property in the JSON you have shown. So:

    success: function (data) {
        response(
            $.map(data, function (item) {
                return {
                    label: item.label,
                    value: item.value
                };
            })
        );
    },
    

    But if you use an ASP.NET Page method then you have the .d property and you don’t need to manually serialize the JSON. For example, you could have the following PageMethod in your code behind:

    [WebMethod]
    public static List<AutoCompleteItem> GetAutoCompleteValues(string term)
    {
        // the term variable will contain what the user entered so far
    
        var autoCompleteItems = new List<AutoCompleteItem>();
        // Loop through data, add objects to list
        return autoCompleteItems;
    }
    

    and then:

    source: function(request, response) {
        $.ajax({
            url: '/foo.aspx/GetAutoCompleteValues',
            type: 'POST',
            contentType: 'application/json',
            data: JSON.stringify({ term: request.term }),
            success: function(data) {
                response(
                    $.map(data.d, function(item) {
                        return {
                            label: item.label,
                            value: item.value
                        };
                    });
                );
            })
        });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a feeling there is a simple/built-in way to do this but I
I have the feeling the answer to this question is no but I figured
I have a feeling the answer is simple and documented, but I'm absolutely missing
I have a feeling that the answer to this is easy but I can't
I have a feeling that this question is very simple, but I just can't
I have a feeling there is a simple way to do this. I have
I have a feeling this is a stupid question but I can't find the
I have a feeling I am completely borking this MySQL query but I'll ask
I have a feeling my problem is a bit strange, but here goes... I
I have a feeling this XML is not valid, can someone please explain why?

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.