Answer the question
In order to leave comments, you need to log in
I want to redirect to the "thank you" page. What's wrong with my JS?
I want to make a redirect to the "thank you" page What's wrong in my JS
This is how it works with the output of text on the screen "Message sent successfully"
// Отправка данных на сервер
$('#form').trigger('reset');
$(function() {
'use strict';
$('#form').on('submit', function(e) {
$('.msg').removeClass('error success');
$('input').removeClass('inputerror');
loadanim.play();
e.preventDefault();
$.ajax({
url: 'send.php',
type: 'POST',
contentType: false,
processData: false,
data: new FormData(this),
success: function(msg) {
console.log(msg);
if (msg == 'ok') {
$('#form').trigger('reset');
$('.amount').text('Выберите файлы');
$('label').removeClass('active');
$('.msg').text('Сообщение успешно отправлено').addClass('success');
showmsg.restart();loadanim.duration(0.3).reverse();
} else {
if (msg == 'mailerror') {
$("#email").addClass('inputerror');
}
$('.msg').text('Ошибка. Сообщение не отправлено').addClass('error');
showmsg.restart();loadanim.duration(0.3).reverse();
}
}
});
});
});
// Отправка данных на сервер
$('#form').trigger('reset');
$(function() {
'use strict';
$('#form').on('submit', function(e) {
$('.msg').removeClass('error success');
$('input').removeClass('inputerror');
loadanim.play();
e.preventDefault();
$.ajax({
url: 'send.php',
type: 'POST',
contentType: false,
processData: false,
data: new FormData(this),
success: function(msg) {
console.log(msg);
if (msg == 'ok') {
$('#form').trigger('reset');
$('.amount').text('Выберите файлы');
$('label').removeClass('active');
$('.msg')window.location.href = "thanks.html"; .addClass('success');
showmsg.restart();loadanim.duration(0.3).reverse();
} else {
if (msg == 'mailerror') {
$("#email").addClass('inputerror');
}
$('.msg').text('Ошибка. Сообщение не отправлено').addClass('error');
showmsg.restart();loadanim.duration(0.3).reverse();
}
}
});
});
});
Answer the question
In order to leave comments, you need to log in
$('.msg')window.location.href = "thanks.html"; .addClass('success');
if (msg == 'ok') {
window.location.href = "thanks.html";
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question