I have some js that catches when a button is clicked, it works fine but I want to redirect the browser after div is hidden but it doesnt work? Any ideas?
The js code is :
$(function() {
$('form').on('submit', function(e) {
e.preventDefault();
$('.output_message').text('Logging job...');
var form = $(this);
$.ajax({
url: form.attr('action'),
method: form.attr('method'),
data: form.serialize(),
success: function(result) {
if (result == 'success') {
$('.output_message').text('Message Sent!');
form[0].reset();
$('#5box').hide();
window.location.replace("index.php");
} else {
$('.output_message').text('Error Sending email!');
}
}
});
});
});