You can use setTimeout()
Do so:
$("form").submit(function(){
setTimeout(function() {
window.location = 'minha URL';
}, 5000);
}
After clicking the button will execute the function setTimeout()
which receives a function to be executed and the time in milliseconds, after that time it executes the function passed.
You can still assign the function to a variable to cancel later, for that you would use the function clearTimeout()
receiving the variable with the function to be canceled:
$("form").submit(function(){
var timeout = setTimeout(function() {
window.location = 'minha URL';
}, 5000);
//Parar timeout
clearTimeout(timeout);
}
Use
setTimeout
– Leonardo Rodrigues
You can show me what the code would look like
– Hemerson Prestes
Utilize
setTimeout(function(){ window.location = 'minha URL'; }, 5000);
– Leonardo Rodrigues