簡體   English   中英

在 ajax 調用成功后將 ajax 響應數據傳遞到另一個頁面

[英]passing the ajax response data to another page after ajax call on success

我有 ajax 調用並提取數據,我想將響應發送到 ajax 成功的下一頁並在鑽取中獲取數據。html

 $.ajax({
         type: "POST",
         url: "drilldown.php",
         data:data,
        success: function(response){
          window.location.href = 'drilldown.php'; // want to post the data this in redirection
      }
});

如果不涉及服務器端,您可以使用Window.localStorage保存數據(檢查瀏覽器兼容性是否適合您)

 $.ajax({
         type: "POST",
         url: "drilldown.html",
         data:data,
        success: function(response){
          localStorage.setItem('myData', data);
          window.location.href = 'drilldown.html'; // want to post the data this in redirection
      }
});

drilldown.html頁面上,您可以通過 JavaScript 讀取數據

var data = localStorage.getItem('myData');

還有sessionStorage將在瀏覽器重新啟動后被清理。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM