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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T16:16:59+00:00 2026-06-09T16:16:59+00:00

I would like to be able to show a loading icon in the autocomplete

  • 0

I would like to be able to show a loading icon in the autocomplete dropdown while the searching is happening. How can I go about doing this?

Current code:

$("#searchbox").autocomplete({
  search: function(event, ui) {
    $('ul.ui-autocomplete').append("<li id='loading_icon'></li>");
    $('ul.ui-autocomplete').show();
  },
  open: function(event, ui) {
    $('#loading_icon').hide();
  }
 ...

But what happens is the icon shows at the very top left of the browser page. The computing of the location hasn’t happened yet. Can i somehow make a call to compute the location of the autocomplete dropdown box?

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-06-09T16:17:01+00:00Added an answer on June 9, 2026 at 4:17 pm

    This is doable, but you’ll have to convert your source option to a function and make the AJAX request yourself. For example:

    $("#selector").autocomplete({
        source: function (request, response) {
            /* Show the loading indicator while a search is in progress */
            response([{ label: "Loading...", loading: true }]);
            $.ajax({
                url: "your_url_here",
                data: request,
                type: "GET",
                dataType: "json"
            }).success(response);
        },
    }).data("autocomplete")._renderItem = function (ul, item) {
        var $li = $("<li></li>")
            .data("item.autocomplete", item)
            .append("<a>" + item.label + "</a>")
            .appendTo(ul);
    
        /* Make sure nothing happens when you click "Loading" */
        if (item.loading) {
            $li.find("a").on("click", false);
        }
    };
    

    The last bit that overrides _renderItem is doing so so that we can cancel the click event of the loading item (and prevent it from being placed in the input).

    Example: http://jsfiddle.net/m3MGH/


    Update, per comment below:

    To show a loading image in a div, you could do something like this (just changing the _renderItem function):

    .data("autocomplete")._renderItem = function(ul, item) {
        var $li = $("<li></li>");
    
        if (item.loading) {
            $li.append("<div>Loading<img src='my_loading_img' /></div>").appendTo(ul);                
        } else {
            $li.data("item.autocomplete", item).append("<a>" + item.label + "</a>").appendTo(ul);
        }
    
        return $li;
    };
    

    You’ll probably have to use a little CSS to get things positioned just right, but this should get you started.

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

Sidebar

Related Questions

I would like to be able to show whats happening on my phone, on
I would like to be able to show a personal message to abusers of
I have a case where I would like TreeView to be able to show
I would like to be able to show short news messages to users of
I would like to be able to show ContactCard/PopupContactCard control on MouseEnter event of
Would like to be able to set colors of headings and such, different font
I would like to be able to output the name of a variable, along
I would like to be able to print in the logs a message for
I would like to be able to create a variable that holds an instance
I would like to be able to go: sed s/^\(\w+\)$/leftside\1rightside/ and have the group

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.