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

210
Views
How to execute code only after the submission is done?
  1. I have some code from a service called webflow where the form is controlled by them. I write the html form, but the form submission code is handled by a third party not me
  2. I need to run some code (trigger a redirect) after their submission is done.

Here is my attempt

$('#email-form').submit(function (event) {      
    window.location.href = url;
});

It works in some browser, but not in safari. Apparently, this breaks this original form submission code.

My second attempt, this works

    $('#email-form').submit(function (event) {      
    setTimeout(function(){
    window.location.href = url;
    }, 500);

});

By giving it some time, the submission code fires first, then my code runs and successfully redirects.

What is a more robust way of writing this code (not reliant on some random timer wait)?

about 4 years ago ยท Juan Pablo Isaza
1 answers
Answer question

0

I think the best way to work this in every browser is ๐Ÿ‘‡

setTimeout(function(){document.location.href = "your link";},250);
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!