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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T01:22:24+00:00 2026-05-22T01:22:24+00:00

I have the following code: // Autocomplete search $(#shop_search).autocomplete({ source: ‘<%= spotify_search_path(:json) %>’, minLength:

  • 0

I have the following code:

// Autocomplete search
    $("#shop_search").autocomplete({
      source: '<%= spotify_search_path(:json) %>',
      minLength: 1,
      select: function(event, ui) {
        append_place(ui.item.name, ui.item.id, ui.item.shop_type, ui.item.address_geo, ui.item.contact, ui.item.email, ui.item.web);
        $("#shop_search").val('');
      }
    }).data( "autocomplete" )._renderItem = function( ul, item ) {
      return $( "<li></li>" )
      .data( "item.autocomplete", item )
      .append( "<a>" + "<span class='autocomplete_link'>" + item.name + "</span>" + "<br />" + "<span class='autocomplete_address'>" + item.address_geo + "</span>" + "</a>" )
      .appendTo( ul );

      $(".ui-autocomplete-loading").ajaxStart(function(){
        $(this).show();
      });

      $(".ui-autocomplete-loading").ajaxStop(function(){
        $(this).hide();
      });

    };

Currently it only shows the drop down autocomplete when there is search result. I want it to show “No matches found” when nothing could be found. What should I add into the code?

Thanks.

  • 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-22T01:22:24+00:00Added an answer on May 22, 2026 at 1:22 am

    If you use a jQuery ajax call for the source, you can append “No results found” to the results if there aren’t any. Then on the select method, you can simply check to see if the item is the “no results found” item that you added and if so, do nothing. Here I identified that by checking to see if the id was equal to zero.

    $("#shop_search").autocomplete({
        source: function (request, response) {
            $.ajax({
                url: "<%= spotify_search_path(:json) %>",
                data: {
                    term: request.term
                },
                success: function (data) {
                    if (data.length == 0) {
                        data.push({
                            id: 0,
                            label: "No results found"
                        });
                    }
                    response(data);
                }
            });
        },
        select: function (event, ui) {
            if (ui.item.id != 0) {
                append_place(ui.item.name, ui.item.id, ui.item.shop_type, ui.item.address_geo, ui.item.contact, ui.item.email, ui.item.web);
                $("#shop_search").val('');
            }
        }
    });
    

    You’ll need to do some work on your template to get the “no results found” to display properly, but this should get you on the right track.

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

Sidebar

Related Questions

I have the following code: $(#auto).autocomplete({ source: js/search.php, minLength: 3 }); This code is
I have the following code - http://jsfiddle.net/vcvsb/1/ - per $(document).ready(function(e) { $(input#autocomplete).autocomplete({ source: [c++,
I have the following function: $('#s').autocomplete({ source: function(request, response) { $.get( http://theurl.com/?ajax=true, {s: request.term
I am using jQuery autocomplete pluggin . I have the following code $().ready(function() {
I have the following code: var acOptions = { source:function (request, response) { $.ajax({
I am implementing the Jquery UI autocomplete. I have the following code. Application.js $(function()
I have the following code that gives me a an array in an autocomplete
I have the following code to parse the country when the autocomplete list is
I have following code for an autocomplete box, I'm adding an image for choice
I Have following code: Controller: public ActionResult Step1() { return View(); } [AcceptVerbs(HttpVerbs.Post)] public

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.