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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:10:18+00:00 2026-05-26T02:10:18+00:00

I have a text box for searching my photos website. As a user types,

  • 0

I have a text box for searching my photos website. As a user types, instead of showing a list of suggestions, I would like to show a count of results, informing my user that there are photos for what they are typing.

I will add an ‘onChange’ event to my text box, that will call my AJAX function. The function will then gather what has been typed already, AJAX it to my ASP page that produces the count and posts it back to display.

I know how to accomplish this but I don’t know how it will work on performance. The problem I foresee is if the user types a really long string, really quickly, it might have to do 50 calls (for each character in string). The ASP/SQL search query, that produces the count, is also very large, and can take between 0.8 – 1.0 seconds to produce a count.

Is this going to cause me problems? How will this actually work? If the user is typing character 42, will the AJAX still be processing character 12, trying to catch up with the user? Will it jam? If another call is made does it cancel the old one if it hasn’t got a response?

Any suggestions/experiences gratefully received.

  • 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-26T02:10:19+00:00Added an answer on May 26, 2026 at 2:10 am

    The solution that I typically provide for my own applications is to ONLY initiate an ajax request after the user has stopped typing for a certain period of time (say, 0.75 seconds). For every keystroke, [re]start a javascript timeout (setTimeout) for some time (perhaps 0.75 seconds). Each keystroke that a user generates cancels this timeout and restarts it. This way the ajax will only happen after the user hasn’t typed anything for that period of time (0.75 seconds). Here is some code to demonstrate.

    var __global_timeout = null;
    function getResultCountWrapper () {
        if (__global_timeout)
            clearTimeout(__global_timeout);
        __global_timeout = setTimeout(getResultCount, 0750);
    }
    
    function getResultCount () {
        // ajax call goes here.
    }
    

    This is what you would place on your text input box.

    <input type="text" onchange="getResultCountWrapper()";>
    

    Here is a complete web page that works as advertised:

    <html>
      <head>
        <script type="text/javascript">
          var __global_timeout = null;
          function getResultCountWrapper () {
            if (__global_timeout)
              clearTimeout(__global_timeout);
            __global_timeout = setTimeout(getResultCount, 0750);
          }
    
          function getResultCount () {
            // ajax call goes here.
            alert('wee');
          }
    
        </script>
      </head>
      <body>
        <input type="text" onchange="getResultCountWrapper()";>
      </body>
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a text box for searching. For some reason, .blur() will not work
i have form where i have text box value and link (add). when user
I have a text-box into which a user can input a comment. The comment
I have one text box and i have to show minimum date of the
I have written a user control that contains a text box and a button.
I have a DDL and ASP.NET Textbox. I would like to populate the text
I have two controls: list box text box The list box binds its data
I have a form with a text box for a user to enter a
I have text box to enter a phone number. I'm using AJAX MaskedEditExtender and
I have text box in which your adds values in comma separated values. Once

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.