当您单击一个按钮时,会打开带有表单的 fancybox,填写表单并单击发送按钮后,我希望此窗口自动关闭,并打开另一个窗口,并显示“消息已成功发送”文本几秒钟后,或者在窗口区域外按下时,它就会消失。
$("form").submit(function() { //Change
var th = $(this);
$.ajax({
type: "POST",
url: "mail.php", //Change
data: th.serialize()
}).done(function() {
$('#alert-massage').fadeIn(500);
alert("Thank you!");
setTimeout(function() {
// Done Functions
th.trigger("reset");
}, 1000);
});
return false;
});
<div id="modal">
<div class="modal__wrap">
<div class="modal__title">
Write me
</div>
<form >
<!-- Hidden Required Fields -->
<input type="hidden" name="project_name" value="kylun-Serg">
<input type="hidden" name="admin_email" value="kylun1serg@gmail.com">
<input type="hidden" name="form_subject" value="popup-form">
<!-- END Hidden Required Fields -->
<input type="text" placeholder="Username" name="Name" required>
<input type="email" placeholder="Email" name = "E-mail"required>
<input type="phone" placeholder="Phone" name = "Phone">
<textarea placeholder="Massage" name="Massage"></textarea>
<button type="submit" class="btn">
Send
</button>
</form>
</div>
猛跑小猪
相关分类