除了 之外,是否可以ajax应用两个表单处理程序mail.php?
$("#form").submit(function() {
var th = $(this);
$.ajax({
type: "POST",
url: "../mail.php",
data: th.serialize()
}).done(function() {
alert("Thank you, your message was sent.");
setTimeout(function() {
th.trigger("reset");
}, 1000);
});
return false;
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
使用 Promise.all 发送两个请求并在两者都成功时执行回调。