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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T18:12:08+00:00 2026-06-02T18:12:08+00:00

I have a script that searches my site for duplicate content as a user

  • 0

I have a script that searches my site for duplicate content as a user is typing in the title of a new post (just like on Quora). Right now it fires off a post request on keyup, leading to stacking of post requests.

Any ideas on the best way to avoid this?

$("#topic_title").keyup(function(){
    var search_val=$(this).val(); 
    $.post('/?post_type=topic&duplicate=1',{s:search_val},function(data){
        if(data.length>0){
           var results = $(data).find( '#results' );
           $("#duplicates").html(results);
        }

     });
});

** Thanks for all of the quality answers! I went with the abort() method for simplicity. Works like a charm.

  • 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-02T18:12:10+00:00Added an answer on June 2, 2026 at 6:12 pm

    There are 2 things I will generally do in a situation like this:

    1. Only send off the request after no key is pressed for a certain time period, say .5 a second. This way if a person is typing quickly, you don’t send off 10 requests, you just send one when they stop typing. This can be done by using setTimeout and clearTimeout.

    2. When a new request is sent, cancel the previous. This way there is only ever one active request. You really only care about the latest anyway. This can be done by using abort().

    A rough outline:

    var timeout;
    var xhr;
    
    $("#topic_title").keyup(function(){
        if(timeout) clearTimeout(timeout);
        if(xhr) xhr.abort();
    
        timeout = setTimeout(function(){
            doThePost(<parameters>);
        }, 500);
    });
    
    function doThePost(){
        xhr = $.post(...);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a script that searches for a directory containing a specific file, starting
I have a line in a bash script that searches for a folder using
At the minute I have a page with an AJAX script that searches a
We have a small php script, that displays random adverts on our site .
I have a script that updates a CSS file based upon some user input
I have a script that searches for users in the db. I have two
Currently im faced with the following problem: I have a script that searches through
I have a site that is Ajaxed, content that is Ajax is from other
I have a jquery script that searches a php file that produces an XML
I have a jQuery search script that uses tabs for the user to define

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.