繁体   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