调用一个新的 PHP 页面并传递一个长文本



>我有一个PHP页面(主(,想在鼠标点击时调用另一个PHP页面(打印页面(。 我需要传递一个大文本。

我不想将其作为 url 参数传递,因为它太大了。 我想我想把它作为 ajax 传递,但我想打开打印页面,以便我可以在浏览器中打印它。

I started with this but the paramater will be too big
$('#MyModal .print').click(function() {
var   run = "../js/print.php?ref="+ref;
win = window.open(run, '_blank');
win.focus();
});

我熟悉 ajax 语句,但还没有打开新页面。

您可以使用带有target="_blank"的不可见表单并method="post"并提交它,从而在新窗口中发送 POST 请求:

<form name="printForm" style="display: none;" action="../js/print.php" method="post" target="_blank">
<input type="hidden" name="ref">
</form>
$('#MyModal .print').click(function() {
document.forms.printForm.ref.value = ref
document.forms.printForm.submit()
})

然后你在 PHP 中得到ref值作为$_POST['ref']

相关内容

最新更新