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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:40:46+00:00 2026-05-26T08:40:46+00:00

I’ve been banging my head against this issue for a while now and I’m

  • 0

I’ve been banging my head against this issue for a while now and I’m not sure what I’m doing wrong.

I have a very simple JSON call to one of my controllers that I want to return client names along with the relevant ID values using jquery ui autocomplete. I can see the results in Firebug but the autocomplete is always returning an empty list.

The number of items in the list generated by jquery is correct – for example, if I am returned 3 results then I see the suggest menu with 3 blank list items. The problem seems to be that the jquery does not parse my response correctly.

I am not using jquery validate on the textbox as some other questions on here have suggested.

I am running this locally if that makes a difference.

Below is the jquery/HTML I use:

<script src="https://www.google.com/jsapi" type="text/javascript"></script>
<script type="text/javascript">        google.load("jquery", "1.6.4")</script>
<script type="text/javascript">        google.load("jqueryui", "1.8.16")</script>
<script type="text/javascript">
    $(document).ready(function () {
        $("#clientEntered").autocomplete({
            source: '@Url.Action("ClientAutoSuggest", "Clients")'
        });
    });

</script>

<input type="text" name="clientEntered" id="clientEntered" />

My controller looks something like this:

public JsonResult ClientAutoSuggest(string term)
    {
        var filteredClients = (from c in clientService.GetClients()
                               where c.Name.ToLower().StartsWith(term.ToLower())
                              select new { ClientID = c.ClientID, Name = c.Name }).Take(10);

        return Json(filteredClients, JsonRequestBehavior.AllowGet);
    }

As mentioned above, I do see results passed back in Firebug but the generated list is always empty.

Example – if 2 results are returned I will see the 2 results in Firebug:

[{"ClientID":1,"Name":"Client 1"},{"ClientID":2,"Name":"Client 2"}]

If I look at the generated source I see the following (correct 2 items but blank):

<ul style="z-index: 1; top: -16px; left: 0px; display: block; width: 1864px; position: relative;" aria-activedescendant="ui-active-menuitem" role="listbox" class="ui-autocomplete ui-menu ui-widget ui-widget-content ui-corner-all"><li></li><li></li></ul>

I have tried different configurations for parsing the response but nothing I try seems to work. Any suggestions or help would be great, thanks!

EDIT: Got it working thanks to Kevin’s answer below. The issue was down to not mapping the response correctly. The code below works great now.

$("#clientEntered").autocomplete({
            source: function(request, response) {
            $.ajax({
              url: '@Url.Action("ClientAutoSuggest", "Clients")',
              data: request,
              dataType: "json",
              type: "POST",
              success: function(data){
                  response($.map(data,function(item){
                  return { label: item.Name,value: item.Name, id: item.ClientId }
                  }));
              }
            });
           },
        });
  • 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-26T08:40:47+00:00Added an answer on May 26, 2026 at 8:40 am

    I don’t see any reference 2 the actually autocomplete JS? You probably have it somewhere else but I just wanted to let you know.

    The real problem probably is caused by your ‘@Url.Action’. It will just execute that action and return the results. There is *no mapping to the textbox.

    The best practice would just to make a simple Ajax call and do the mapping when you receive the response.

    Should be something like this, just wrote it quick so don’t shoot me but you should get the picture 😉

    $("#clientEntered").autocomplete({
                source: function(request,response)
                {
                   $.ajax({
                     url: "/Clients/ClientAutoSuggest",
                     type:"POST",
                     dataType:"json",
                     data: { term: request.term },
                     success:function(data){
                        response($.map(data,function(item){
                          return { label: item.Name,value: item.Name, id: item.ClientId
                        }))
                     }
    
                    })
                }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have some data like this: 1 2 3 4 5 9 2 6
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a French site that I want to parse, but am running into

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.