0

This is the situation: I have 2 files, reportCaller.php and report.php. From the reportCaller.php, the user is going to press a button with the method "onclick", this will call the function that is going to do the ajax/post stuff (this is with what im having problems), report.php is going to catch some parameters by POST and has to be opened on a new Tab or Window, this is going to display a report. (Note: May be not important, but im using HTML2PDF).

reportCaller (HTML):

<input type="button" onclick="generateReport()">

reportCaller (JS):

function generateReport(){

  var id = '¡I must reach the report FILE!';
  //I tried a couple stuff, but didnt work, this is one:
     $.ajax({
        type: "POST",
        url: "report.php",
        data: {id:id},
        cache: false,
        success: function (html) {
            myWindow = window.open(encodeURIComponent(true),
                "_blank");
            myWindow.focus();
    });

}

report:

$id = $_POST['id'];
//This file (report.php) must catch $_POST, will not help if i only open the file in a new Tab/Window

Thanks for reading.

1 Answers1

2

This is more of a comment than an answer, but I haven't got the reputation ;-)

take a look at Javascript Post on Form Submit open a new window

the trick is to put your button in a

<form target="_blank">

Element and then send that form..

You could do your processing of data in the onsubmit Handler

Community
  • 1
  • 1