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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T10:34:18+00:00 2026-06-05T10:34:18+00:00

I am using JQuery autocomplete in one of our web pages which gets source

  • 0

I am using JQuery autocomplete in one of our web pages which gets source data from a url and wokring ok.
{

   $(function () {

        $("#name-list").autocomplete({
            source: function (request, response) {
                $.ajax({
                    url: "/MemberType/FindMemberTypes", type: "POST", dataType: "json",
                    data: { searchText: request.term, maxResults: 10 },
                    success: function (data) {
                        response($.map(data, function (item) {
                            return { label: item.DisplayText, value: item.description, id: item.id }
                        }))
                    }
                })
            },
            select: function (event, ui) {
                alert(ui.item ? ("You picked '" + ui.item.label + "' with an ID of " + ui.item.id)
                    : "Nothing selected, input was " + this.value);
            }
        });

    });

}

The url “membertype/findmemberTypes” searches memberType table and returns list of member types in Json format.

The problem I have here is every time the use keys in some character in the textbox, ONE request is made to the server,the table is scanned and the data is returned to the caller. I want to change the behavior in such a way that there is only one trip to the server when user really wants to search for the text.

Is it possible to trigger auto-complete only after user presses “Enter key” in the textbox?

  • 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-05T10:34:20+00:00Added an answer on June 5, 2026 at 10:34 am

    Thanks Guys for your answers and time.

    After mocking around for a while, I found a solution to this which just suits my requirement.

    I just added some code to disable the autocomplete altogether and enable it only when user presses enter. When user tries to enter a different text by pressing backspace or delete keys, feature is disabled back again.

    <input type="text" id="name-list" /> (Press enter for options)
    
    <script type="text/javascript" language="javascript">
        $(function () {
    
    
    
            $("#name-list").autocomplete({
    
                source: function (request, response) {
                    $.ajax({
                        url: "/MemberType/FindMemberTypes", type: "POST", dataType: "json",
    
                        data: { searchText: request.term, maxResults: 10 },
                        success: function (data) {
                            response($.map(data, function (item) {
                                return { label: item.description, value: item.description, id: item.id }
                            }))
                        }
                    })
                },
    
                select: function (event, ui) {
                    alert(ui.item ? ("You picked '" + ui.item.label + "' with an ID of " + ui.item.id)
                        : "Nothing selected, input was " + this.value);
    
                }
            }).keypress(function (e) {
                if (e.keyCode === 13) {
                    $("#name-list").autocomplete("enable");
                    $("#name-list").autocomplete("search", $("name-list").val());
                }
                else if ((e.keyCode == 8) || (this.value == "") || (e.keyCode == 46)) 
                {
                    $("#name-list").autocomplete("disable");
                }
    
    
            }); ;
    
            $("#name-list").autocomplete("disable");
    
        });
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using jQuery autocomplete plugin from jQuery website calling the controller url which return
The question says it all. My jquery autocomplete gets its source from one of
I have an input box for which I am using the Jquery autocomplete function.
I'm using ajax function to get the data back for my jquery autocomplete but
I am using jquery.autocomplete.js and jquery.apitags to select a few elements from a div
I'm using jQuery UI Autocomplete plug-in. I'm giving it an URL to make an
What's benefit using jQuery Autocomplete over Ajax AutoCompleteExtender? Can some one explains the benefits
I am using older JQuery Autocomplete plug-in (the one shown here - http://view.jquery.com/trunk/plugins/autocomplete/demo/ ).
I am using jquery-rails-autocomplete and want to have autocomplete on more than one column.
I am using jQuery autocomplete pluggin . I have the following code $().ready(function() {

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.