簡體   English   中英

在 jquery 的 post 中傳遞參數

[英]passing the parameter in post in jquery

我想將響應數據傳遞到 ajax 成功的另一個頁面。

我在 laravel 中使用 jquery。 我已經調用了 function 並在成功調用中從 controller 獲取數據。 我想將接收到的數據傳遞給另一個頁面詳細信息

$.ajax({
  type: 'get',
  url: 'am_detailed_report', //send the request to the controller
  data: {
    am_geo_selection: am_geo_selection
  },
  dataType: 'json',
  success: function(data) {
    console.log(data);
    $url = "am_detailed?filter=" + data;
    window.open($url, "_blank"); //want to send the parameter in post instead of passing it in url.
    $('.loaderImage').hide();
  },
  error: function(jqXHR, textStatus, errorThrown) {
    $('.loaderImage').hide();
  }
});

嘗試這個

$.ajax({
  type: 'get',
  url: 'am_detailed_report', //send the request to the controller
  data: {
    am_geo_selection: am_geo_selection
  },
  dataType: 'json',
  success: function(data) {
    console.log(data);
    $url = "am_detailed"
    const html = `<form action="${url}" method="post">
      <textarea name="filter">${data}</textarea>
      </form>`
    const w = window.open("", "_blank"); 
    w.document.write(html);
    w.document.close();
    w.document.querySelector("form").submit()
    $('.loaderImage').hide();
  },
  error: function(jqXHR, textStatus, errorThrown) {
    $('.loaderImage').hide();
  }
});

暫無
暫無

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

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