0

I want to pass the response data to another page in ajax success.

I'm using jquery in laravel. I have called the function and get the data from the controller in success call. I want to pass the received data to another page detail

$.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();
  }
});
mplungjan
  • 169,008
  • 28
  • 173
  • 236
user3386779
  • 6,883
  • 20
  • 66
  • 134

1 Answers1

0

Try this

$.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();
  }
});
mplungjan
  • 169,008
  • 28
  • 173
  • 236