【问题标题】:passing the parameter in post in jquery在 jquery 的 post 中传递参数
【发布时间】:2020-12-04 12:58:04
【问题描述】:

我想将响应数据传递到ajax成功的另一个页面。

我在 laravel 中使用 jquery。我已经调用了该函数并在成功调用中从控制器获取数据。我想将接收到的数据传递给另一个页面详细信息

$.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();
  }
});

【问题讨论】:

标签: javascript jquery ajax


【解决方案1】:

试试这个

$.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();
  }
});

【讨论】:

    猜你喜欢
    • 2016-12-21
    • 1970-01-01
    • 1970-01-01
    • 2014-12-19
    • 2015-09-25
    • 1970-01-01
    • 2011-10-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多