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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T15:59:27+00:00 2026-05-15T15:59:27+00:00

Alright so I’ve got this script sort of working. The ajax call works and

  • 0

Alright so I’ve got this script sort of working. The ajax call works and the correct data is returned. The problem is that when keystrokes are pressed quickly (not real quickly, just normal typing speed), then the animations keep going back and forth, and every ajax call is still executed.

How can I make it so that:

1) the ajax calls don’t stack up
and
2) the fadein and fadeout animations don’t keep stacking up

I have this javascript:

    $(document).ready(function(){

$t = $("#data-users");

$('#data-overlay').css({
  opacity : 0.5,
  top     : $t.offset().top,
  width   : $t.outerWidth(),
  height  : $t.outerHeight()
});

$('.loader').css({
  top  : ($t.height() / 2),
  left : ($t.width() / 2)
});

    $('.findit').keyup(function(){
        var search;
        search = $(this).val();
            $('#data-overlay').fadeIn();
            //get the data
            $.post(
            '/users/testajax',
            {
            search: search
            },
            function(responseText){
                $("#data-users").html(responseText);
                $('#data-overlay').fadeOut();
            },
            'html'
            );

    });
});
  • 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-15T15:59:27+00:00Added an answer on May 15, 2026 at 3:59 pm

    Two suggestions: one is to use the .ajaxStart() and .ajaxComplete(), which ensures that if a second ajax call is queued, complete is only called once. But you may still see flicker, if the response time of the ajax call is less than the users typing speed.

    You may also be getting continuous ‘blinking’ long after typing stops because multiple fadein/fadeout animations are queued. To avoid that use the stop(false,false) function.

    To reduce the number of ajax calls (thus the number of fadein/fadeout as well) put a short delay on the keyup function so the ajax call is made after a short delay, and if a user types quickly, only one call is made.

    Combining the three:

    jQuery.fn.keyupQueue = function(callback, delay) {
        return this.each(function(){
            var timer = null;
            $(this).keyup(function() {
                if (timer)
                    window.clearTimeout(timer);
                timer = window.setTimeout( function() {
                    timer = null;
                    callback();
                }, delay || 200);
            });
        });
    };
    
    $("#data-overlay").bind("ajaxSend", function(){
        $(this).stop(true,true).fadeIn();
    }).bind("ajaxComplete", function(){
        $(this).stop(true,true).fadeOut();
    });
    
    $('.findit').keyupQueue(function(){
        $.post('/users/testajax', 
               { search: $(this).val() },
               function(responseText){
                   $("#data-users").html(responseText);
               },
               'html'
              );
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Alright, I wanna know why this code is working, I just realized that I
Alright, I understand that this problem has been asked a lot of times at
Alright I don't see why this isnt working. It seems pretty simple. Here is
Alright, this is driving me nuts because my regex is working on Rubular, but
Alright, so I got this code for gluLookAt: lookAt = new Vector3f(-player.pos.x, -player.pos.y, -player.pos.z);
Alright so this is a bizarre cross platform thing that I'm experiencing with text
Alright, this problem seems to be way above my head! I have this code:
Alright, I'm working on a (supposed-to-be) simple counting script using ncurses. Everytime it increments
Alright. I have a query that looks like this: SELECT SUM(`order_items`.`quantity`) as `count`, `menu_items`.`name`
Alright, so I'm about 90% sure that this isn't possible, but I thought I'd

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.