这就是情况:reportCaller.php I有2个文件,和report.php。在reportCaller.php中,用户将使用"onclick“方法按下一个按钮,这将调用要执行ajax/post内容的函数(这与我遇到的问题有关),report.php将通过POST捕获一些参数,并必须在新的Tab或窗口上打开,这将显示一个报告。(注:可能不重要,但我使用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();
});
}报告:
$id = $_POST['id'];
//This file (report.php) must catch $_POST, will not help if i only open the file in a new Tab/Window感谢您的阅读。
发布于 2015-03-11 16:11:45
这与其说是回答,不如说是评论,但我还没有得到这个声誉;-)
看看Javascript Post on Form Submit open a new window
诀窍是把你的按钮放在
<form target="_blank">元素,然后发送该表单。
您可以在onsubmit Handler中处理数据。
https://stackoverflow.com/questions/28991119
复制相似问题