jQuery 在新选项卡中打开页面,同时传递 POST 数据 [英] jQuery open page in a new tab while passing POST data
问题描述
我有一个名为list"的 javascript 变量.我需要将其作为 POST 数据发送到另一个页面,并在新标签页中打开该页面(存在 POST 数据).
I have a javascript variable called "list". I need to send it as a POST data to another page and open that page in a new tab (with the POST data present).
此代码:
jQuery.post('datadestination.php', list);
发送数据没问题,但当然它会在同一个选项卡中打开页面.
sends the data all right, but ofcourse it opens the page in the same tab.
我看到了一些使用隐形形式和类似方法解决类似问题的方法,但我无法让它们发挥作用.有什么简单的解决办法吗?
I saw some solutions to similar problems using invisible form and things like that, but I could not get them to work. Is there any simple solution?
推荐答案
1) 为什么不使用 jquery.post()
函数传递该列表并将其保存在 SESSION
数组;
1) Why not to pass that list with the jquery.post()
function and save it in the SESSION
array;
2) 然后使用 window.open()
函数打开一个具有相同文件/地址/url 的新标签;
2) Then open a new tab with the same file/address/url with the window.open()
function;
3) 从 SESSION
数组中检索保存的数据;
3) Retrieve saved data from the SESSION
array;
看起来是一种简单明了的方式吗?
Seems a straightforward and clean way?
这篇关于jQuery 在新选项卡中打开页面,同时传递 POST 数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!