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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T04:51:24+00:00 2026-05-19T04:51:24+00:00

I have the jquery includes setup correctly I believe, datepicker is working. However, when

  • 0

I have the jquery includes setup correctly I believe, datepicker is working. However, when I put a breakpoint on the controller for the autocomplete it never gets activated when typing in the text box. I have:

    <script type="text/javascript">
    $(document).ready(function () {
        $("input#sitesearchlist").autocomplete('<%= Url.Action("Filter", "Wos") %>');
    });
    </script>

where Filter is an action on the controller Wos as such:

    public ActionResult Filter(string q)
    {
        var siteList = _sitesRepository.GetSites(q);
        return Json(siteList, JsonRequestBehavior.AllowGet);
        //return siteList;
    }

and I realize should probably return a simple list not json to go with the first snippet. Ultimately I need to set an id in the data not the name so this is a simplified example to try to resolve the immediate problem, which is that when i run this there is no data pulled from the controller action, and when I set a breakpoint, it is fired on first run but NOT when you enter text in the text box:

    <%= Html.TextBox("sitesearchlist") %>

So i think the java gets activated for the autocomplete, since at some point it appears to have cached the letters ‘ki’ since if i type them, the list will appear below the text box with just those letters. Still, when you type, action doesn’t fire.

If I visit the url, I do get the json data like:

[{"SiteId":153,"SiteName":"Name of Site"}]

So for some reason no matter what I have tried I get stuck the same way. Autocomplete says to put the java script at the head of the page, which is in my site.master, and the textbox is obviously further down the page. I think if json data was coming (even though controller breakpoint is never hit) and was the wrong format I should get a list of garbage or something in the list, yes? Thanks for any suggestions!!!!

EDIT: found this excellent page and ended up with the following:

    <script type="text/javascript">
    $(document).ready(function () {
        $("#tags").autocomplete({
            source: function (request, response) {
                $.ajax({
                    url: "/Wos/Filter", type: "POST", dataType: "json",
                    data: { searchText: request.term, maxResults: 10 },
                    success: function (data) {
                        response($.map(data, function (item) {
                            return { label: item.SiteName, value: item.SiteName, id: item.SiteId }
                        }))
                    }
                })
            },
            minLength: 3

        });
    });
</script>

and

    [HttpPost]
    public JsonResult Filter(string searchText, int maxResults)
    {
        var siteList = _sitesRepository.GetSites(searchText);
        return Json(siteList, JsonRequestBehavior.AllowGet);
    }

and it is working fine now. Without a full understanding of this (just getting started with java, can’t you tell?) it appears the request/response is what does the trick. This must be due to the mvc2 changes referenced on the page, I assume, since so many working examples are cited here that don’t work for me, even with a simple list, but this does.

  • 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-19T04:51:24+00:00Added an answer on May 19, 2026 at 4:51 am

    EDIT

    Actually it looks like you’re not using autocomplete correctly. See the example here
    http://jqueryui.com/demos/autocomplete/#remote-jsonp

    try doing (Hopefully the parentheses and braces are correct)

    $("input#sitesearchlist").autocomplete({source: function(request, response) {
       $.getJSON('<%= Url.Action("Filter", "Wos") %>', {q: request.term}, function(data) {
           response($.map(data, function(item) {
               return {label: item.SiteName, value: item.SiteId};
           }));
       });
    }});
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have put fancybox (jquery plugin ) inside the assets/javascripts/includes/jquery.fancybox-1.3.4 Before this location i
How have you guys handled working with jQuery includes <script type=text/javascript src=jquery.js></script> in Asp.Net
I am using Rails 3, Jquery-UJS and Jquery. I have a working setup of
I have HTML which includes scripts in following order <script src=../static/js/jquery.js type=text/javascript> <script src=../static/js/bootstrap.js
I'm progamming in javascript/jQuery. Say, I have an array with includes a few number
I have jQuery draggable set up and working ok on a table row. Currently
Below I have a jquery code which includes a textbox where the user can
On my site I have one global Javascript file which includes jQuery and code
I have heard that jQuery UI includes a Color Picker but could find little
I have included Zend_Form_Element_Hash into a form multiplecheckbox form. I have jQuery set to

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.