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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:01:56+00:00 2026-05-26T06:01:56+00:00

I’m having trouble with my auto complete functionality, it hits the controller and returns

  • 0

I’m having trouble with my auto complete functionality, it hits the controller and returns the values but nothing is displayed on the page, I have provided the code below any help is appreciated.

HomeControllerMethod

[HttpPost]
    public JsonResult  GetAccounts(string id)
    {
        var accounts = NavRepository.GetAccountsBasedOnString(id);

        return Json(accounts, JsonRequestBehavior.AllowGet);
    }

About.cshtml

 <link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.14/themes/base/jquery-ui.css" type="text/css" media="all" /> 
<script src="@Url.Content("~/Scripts/jquery-1.5.1.min.js")" type="text/javascript">      </script>
<script src="@Url.Content("~/Scripts/jquery-ui-1.8.11.min.js")" type="text/javascript">      </script>


<script type="text/javascript">
$(function () {
    $('#searchTerm').autocomplete({
        source: function (request, response) {
            $.ajax({
                url: '@Url.Action("GetAccounts", "Home")',
                data: { id: request.term },
                dataType: 'json',
                type: 'POST',
                minLength: 3,
                success: function (event, ui) {
                    searchTerm.valueOf (ui.item.value);
                }
            });
        } 
    });
});

</script>

@using (Html.BeginForm())
{               
<form method="post" action="">
 <input id="searchTerm" name="searchTerm" type="text" />
     <input type="submit" value="Go" />
 </form>
} 

Edit:
Below is my final function

  $(function () {
    $('#searchTerm').autocomplete({
        source: function (request, response) {
            $.ajax({
                url: '@Url.Action("GetAccounts", "Home")',
                data: { id: request.term },
                dataType: 'json',
                type: 'POST',
                minLength: 3,
                success: function (data) {
                    response(data); ;
                }
            });
        } 
    });
});
  • 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-26T06:01:57+00:00Added an answer on May 26, 2026 at 6:01 am

    A few things:

    1. You need to call the response function that the widget supplies to the source function you provide. Also, it looks like you have one of the autocomplete’s options (minLength) mixed in with the AJAX call:

      $('#searchTerm').autocomplete({
          source: function (request, response) {
              $.ajax({
                  url: '@Url.Action("GetAccounts", "Home")',
                  data: { id: request.term },
                  dataType: 'json',
                  type: 'POST',
                  success: function (data) {
                      response(data); // You may have to perform post-processing here depending on your data.
                  }
              });
          },
          minLength: 3
      });
      
    2. Additionally, make sure that you’re supplying the widget with the data it expects. You need to supply the response function with an array of strings, e.g:

      ["Item1", "Item2", "Item3"]
      

      Alternatively, you can supply an array of objects with a label property, a value property, or both:

      [{ label: "Item1", value: "1" }, { label: "Item2", value: "2" }]
      

      You may already be doing this, but I would have to see what your controller action returns.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a French site that I want to parse, but am running into
I'm having trouble keeping the paragraph square between the quote marks. In firefox the
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I have a jquery bug and I've been looking for hours now, I can't
Basically, what I'm trying to create is a page of div tags, each has
this is what i have right now Drawing an RSS feed into the php,
Seemingly simple, but I cannot find anything relevant on the web. What is 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.