透過在 PHP 中發出 AJAX 呼叫來下載檔案


不建議使用 Ajax 下載檔案。相反,應使用 window.location = 或 document.location

'window.location'具有以下特徵 -

  • 需要啟用 JavaScript
  • 它不需要 PHP 即可。
  • 它有助於顯示站點的內容,並在幾秒鐘後重新定向使用者。

重定向可以依賴於任何條件,例如 -

$success = 1
if ($success) {
   window.location.href = 'http://example.com';
}

將名為“success”的變數分配為值 1。當滿足此條件時,將使用 window.location。

執行後,使用者將被重定向到網站“http://example.com”

更新於: 07-04-2020

2K+ 瀏覽量

開啟您的職業生涯

完成課程以獲得認證

開始
廣告
© . All rights reserved.