Answer the question
In order to leave comments, you need to log in
Closing a pop-up registration form?
How to make the pop-up registration form close via JS after filling:
$("form").on("submit", function (e) {
$(".form").submit(function() {
$.ajax({
type: "POST",
url: "mail.php",
data: $(this).serialize()
}).done(function() {
alert("Спасибо за заявку!");
setTimeout(function() {
$(".forms").trigger("reset");
}, 1000);
});
return false;
});
});
Answer the question
In order to leave comments, you need to log in
$(".forms").trigger("reset");
// После закрываете форму
$('.form').hide() // Прячете
$('.form').remove() // Или вовсе удаляете
In this code, you will have a memory leak. You hang an event when another one has fired and do not remove it. In general, when the .done method has completed, $.ajax must be closed. By code, you simply inform the user that everything is fine, hide the form and nullify the values in it
...
.done(function(data) {
alert("Спасибо за заявку!");
$("ваша форма, либо из замыкания берём").hide();//либо анимацию проиграйте .fadeout();
setTimeout(function() {
$(".forms").trigger("reset");//ресет можно сделать сразу после скрытия формы, таймеры не к чему
}, 1000);
});
....
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question