Jquery - 如何打开一个窗口并发布到它?(银行处理页面需要 - 不接受查询字符串)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1086695/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Jquery - how to open a window and POST to it? (required for bank processing page - doesn't accept querystring)
提问by mark smith
Is there anyway that i can open a new window in the browser using jquery and post to it.
无论如何我可以使用jquery在浏览器中打开一个新窗口并发布到它。
Reason being is my bank requires that i open there payment gateway and pass my values by POST and not GET.
原因是我的银行要求我打开支付网关并通过 POST 而不是 GET 传递我的值。
I have a bit of workaround at the moment but its not idea.. I used QUERYSTRING to an ASPX page withing some hidden forms and submit the form to my bank
我目前有一些解决方法,但它不是想法..我使用 QUERYSTRING 到带有一些隐藏表单的 ASPX 页面并将表单提交给我的银行
but its really not good.
但它真的不好。
Maybe jquery can do this natively or using a plugin?
也许 jquery 可以在本地或使用插件来做到这一点?
回答by Sampson
Stackoverflow Archive:
Stackoverflow 存档:
Javascript Post on Form Submit Open New Window
Accepted Answer:
Add<form target="_blank" ...></form>
orform.setAttribute("target", "_blank");
to your form's definition.
接受的答案:
将<form target="_blank" ...></form>
或添加form.setAttribute("target", "_blank");
到您的表单定义中。
Google Results:
谷歌结果:
回答by marc.d
do you really need a new window? with jQuery.post() ( http://docs.jquery.com/Ajax/jQuery.post#urldatacallbacktype) you could make a async post to the bankpage and display its return value as you like.
你真的需要一个新窗口吗?使用 jQuery.post() ( http://docs.jquery.com/Ajax/jQuery.post#urldatacallbacktype),您可以向银行页面发送异步帖子并根据需要显示其返回值。
maybe the bank page even has the option to return json data instead of plain html.
也许银行页面甚至可以选择返回 json 数据而不是纯 html。
hth
第
回答by ScottE
How about using the target attribute (_blank) of a form and posting to a new window?
如何使用表单的目标属性 (_blank) 并发布到新窗口?
The target attribute of the form element was deprecated in HTML 4.01, and is not supported in XHTML 1.0 Strict DTD, so if that's important to you it won't work.
form 元素的 target 属性在 HTML 4.01 中已被弃用,并且在 XHTML 1.0 Strict DTD 中不受支持,因此如果这对您很重要,它将不起作用。
回答by Allan
I never used JQuery but this is how I do it with plain Java Script.
我从未使用过 JQuery,但这就是我使用普通 Java Script 的方式。
Maybe you can port it to JQuery syntax:
也许您可以将其移植到 JQuery 语法:
window.open("",'myWindow','scrollbars=yes, resizable=yes');
window.setTimeout("document.myFormName.submit();",500);
myFormName has to mach the 'name' attribute of the Form.
myFormName 必须匹配表单的“名称”属性。
see:
看: