Adding a delay to a page transition

Greetings to all !!
I have an issue with adding a delay timing to a transition between a form submission and a move to a confirmation page. I think I have the right code, but can’t quite work out where to place it. Any assistance would be most gratefully received (still on the learning curve :wink: )

Here’s the original code:

“inline-block”);
}
$(“#iris-message”).html(response.text);
if (response.type == “message”) {
var redirect_url = $(‘#redirect_url’).val();
if (redirect_url) ;
window.location.href = redirect_url;
}
$(‘input’).val(‘’);
$(‘select[name=“pp-department”]’).val(‘’);
$(‘textarea[name=“pp-message”]’).val(‘’);
}
},

I believe that the code I need to delay the move to the new page (confirmation page) is :

setTimeout(check, 3000); [to give a 3 second delay]

… but I’m unsure as to exactly where I should place it, or indeed if this is the best solution.

Many thanks in anticipation.

Hey @jeffd2652!
Welcome to the Forum!

That code isn’t formatted too well making it difficult to read, and without any explanation of context it’s even more tricky to guess exactly what’s happening. SetTimout’s first argument is the function you wish to delay, so assuming this redirect is what you wish to delay…

("#iris-message").html(response.text); 
if (response.type == "message") { 
var redirect_url = (’#redirect_url’).val();
if (redirect_url) ;
window.location.href = redirect_url;
}

maybe try wrapping it in a function which you can invoke afterwards with setTimout(). Something along the lines of…

function redirect {
("#iris-message").html(response.text); 
if (response.type == "message") { 
var redirect_url = (’#redirect_url’).val();
if (redirect_url) ;
window.location.href = redirect_url;
}}
setTimeout(redirect, 3000)

:wink: Thanks for the welcome

1 Like

Many thanks for the input. The code is part of a script that I bought that produces a customisable, online form for the web site. As I didn’t actually write the code, I too am at a bit of a loss to fathom what is going on.
The developer did say to include this code, “setTimeout(check, 3000)” but she was a bit vague as to exactly where to place. I think I may seek out a proverbial ‘High Building …’ etc etc ROFLMAO
Thanks again.