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

  • Home
  • SEARCH
  • 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 8871449
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T17:59:45+00:00 2026-06-14T17:59:45+00:00

I want to write a code that behaves like google’s translate form. When I

  • 0

I want to write a code that behaves like google’s translate form.

When I enter a letter in the input text-box, there is a 0.5 second delay that waits for new input. If no new input is received, the request is sent to the server which will return the results on an output text-box.

I wrote something, but it is not complete. Could you help me?!

$(document).ready(function(){
  $('#source').keyup(function(){
    var keyUpTime = $.now();
    setTimeout(function(){
      if($.now() - keyUpTime >= 500) {
        sendValue($('#source').val());
      }         
    },500);         
  });
});

function sendValue(str){
  $.post("ajax.php",{ sendValue: str }, function(data){
    $('#result_box').html(data.returnValue);
  }, "json");
};
  • 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-14T17:59:46+00:00Added an answer on June 14, 2026 at 5:59 pm

    This is what I wonted:

    var keyUpTime = 0;                  
        var t = 0;
        var executeAfterOneSecond = false;
        $('#source').keyup(function(){
            if(executeAfterOneSecond == false){
                executeAfterOneSecond = true;
                t = setTimeout(function(){
                    executeAfterOneSecond = false;
                    sendValue($('#source').val());                          
                    }, 600);
                }                                   
            keyUpTime = $.now();
            setTimeout(function(){
                if($.now() - keyUpTime >= 200) {
                    clearTimeout(t);
                    executeAfterOneSecond = false;
                    sendValue($('#source').val());          
                    }           
                },200);
        });
    

    If the interval between letters is less than 200ms, the request is not sent. If passed 600ms, and the request has not been sent, then request is automatically forwarded. If the interval between letters is more than 200ms, request is send.

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

Sidebar

Related Questions

I want write jquery code that will show form inputs after a checkbox is
I want to write a custom class that behaves like dict - so, I
I want to write a php code that can search for multiple keywords separated
I want to write a java code that executes some Linux command: String cmd
I want to write a parallel code that works on a 3D matrix where
I want to write a line of code that returns a pointer to this
this is my code that I write it but I want to use LINQ
I want to write code that compiles easily for either 32 or 64 bit
I want to write reusable code that takes an HTML table from a JSP
I want to write some code that allows me to replace jQuery's animate 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.