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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T02:52:34+00:00 2026-06-06T02:52:34+00:00

I am using jQuery(Latest release) and have a function called calculate() which gets called

  • 0

I am using jQuery(Latest release) and have a function called “calculate()” which gets called every time a field is edited and the field exited(blur etc). (To allow “dynamic” calculation”)
The calculation takes under 4 seconds to complete, but if the user changes another element on the form before the calculation is complete, then they are queued and the function is called again after the current action is complete.
As I can’t stop the function from processing once it’s started, is it possible to delay the function by a couple of seconds and then each time a form element is interacted with, add to the timer.

I don’t think this is possible, but thoguht i’d give it a shot.

I know I could do:
setTimeout(function(){ ... }, 4000);
but I would need a way to add to this timer. (i.e. The timer has 1 second left, I click on a field and I want the timer to go back to 4 seconds)

  • 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-06T02:52:36+00:00Added an answer on June 6, 2026 at 2:52 am

    What I would do is something like this:

    var isCalculating = false;
    var calculateQueue = false;
    
    function calculate(){
      isCalculating = true;
    
      // do calculations
    
      isCalculating = false;
    
      if(calculateQueue){
        calculate();
      }
    }
    
    $('element').blur(function(){
      if(!isCalculating){
        calculate();
      }
      else{
        calculateQueue = true;
      }
    });
    

    This way you don’t run concurrent calculate() functions. No need for endless timers, and if there are calculations “queued” then they will be calculated after the first calculate function stops… rather than waiting 4s each time. What happens when you change your calculate function and it takes longer?

    Hope this helps.

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

Sidebar

Related Questions

I have a date field (i'm using the jquery ui datepicker) in a form
I have a form using jQuery 1.7 and jQuery validation 1.9 (latest each at
I'm trying to get jQueryMobile working using that latest Alpha release (3) and jQuery
I am using jquery validation 1.9.0. I have used the latest Jquery and on
Using jQuery I want to bind an existing function to a button. I've been
I'm trying to get the font-weight of a property using latest jquery, doesn't work
I'm converting prices using jquery and a php script that pulls in the latest
I am making cross-domain Ajax calls using the latest version of jQuery 1.7.1. with
I'm using: jQuery validation plug-in 1.6 * http://bassistance.de/jquery-plugins/jquery-plugin-validation/ with the latest version of jQuery.
I have a mobile app using JQuery Mobile. Because of issues with blackberry I

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.