Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

155
Views
Timeout a submit animation with JavaScript

i have a submit button and a JavaScript. On click the button changes the state from active to inactive and a spinner animation is shown. I want to add to the script a timeout function. The button shall stop the animation and go back in active state after 3000 ms and show the normal submit button again. Here is my code:

 <button type="submit" class="btn btn-primary btn-lg" value="submit" id="ajax-form-button">Submit</button>

$(document).ready(function() {
 $("#ajax-form").submit(function(e) {
   // disable button
   $('#ajax-form-button').prop("disabled", true);
   // add spinner to button
   $('#ajax-form-button').html(
   `<i class="spinner-border spinner-border-sm mb-1"></i> Bitte warten...`
   );            
 });
}); 

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

window.setTimeout() is what you are looking for.

$(document).ready(function() {
  $("#ajax-form").submit(function(e) {
    // disable button
    $('#ajax-form-button').prop("disabled", true);
    // add spinner to button
    $('#ajax-form-button').html(
      `<i class="spinner-border spinner-border-sm mb-1"></i> Bitte warten...`
    );

    window.setTimeout(() => {
      $('#ajax-form-button').prop("disabled", false); //re-enable button
      $('#ajax-form-button').html("Submit"); // oder "Absenden"  
    }, 3000) // run that function after 3 s

  });
});
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!