我有一個頁面,我想要一個表格完成,一個javascript文件驗證信息,將信息發送到一個php文件郵寄給我,然後啓動下載。 問題是,我可以讓JavaScript文件發送郵件或允許下載文件,但不能同時下載。Javascript運行php文件,然後下載文件
有問題的代碼如下所示:
else {
document.dlform7.action = "http://www.myurl.com/c/post7.php" ;
document.dlform7.submit();
window.location.assign(url);
}
有沒有一種方法(可能使用負載),我可以有這兩種行爲發生在一次?
編輯:
AJAX選項:
else {
$.ajax({
url: "http://www.myurl.com/c/post7.php";
type: "POST",
data: data,
cache: false,
success: function() {
window.location.assign(url);
document.dlform7.submit();
},
將表單提交給一個首先[發送電子郵件](http://stackoverflow.com/questions/5335273/how-to-send-an-email-using-php)的php腳本,然後[下載文件](http://stackoverflow.com/questions/7263923/how-to-force-file-download-with-php) – adeneo