我正在尝试在对话框中将隐藏的 FORM 帖子发送到 iframe 以进行结帐。它是装满购物车并打开带有转移购物车的窗口以在其他地方结账的经典场景(checkoutUrl 在不同的服务器上)。
var form = $('<form>').attr({
id : 'checkoutform',
name : 'checkoutform',
method : "post",
enctype : "multipart/form-data",
action : checkoutUrl,
target : "checkout"
}).appendTo('body');
$('<input>').attr({
type : 'hidden',
name : 'osCsid',
value : osCsid
}).appendTo(form);
var iFrame = $('#iframe');
if (iFrame.length == 0) {
$('<iframe name="checkout" id="iframe" src=""></iframe>').appendTo('body');
iFrame = $('#iframe');
}
iFrame.dialog({
autoOpen : false,
position : [ 'center', 'center' ],
dialogClass : 'shit-theme',
closeOnEscape : true,
modal : true
});
form.submit();
iFrame.dialog('open');
form.remove();
当我检查我的网络日志时,我在加载 iframe 时看到了许多额外的请求:
Name Method Status Type Initiator Size Time Receiving
checkout.php GET 302 text/html jquery.js:5763 542B 142ms 38ms
login.php GET (canceled) undefined http://xdmhost/checkout.php 13B 123ms
checkout.php GET (canceled) undefined jquery.js:5763 13B 3ms
checkout.php GET (canceled) undefined jquery.js:5763 13B 3ms
checkout.php GET (canceled) undefined jquery.js:5763 13B 5ms
checkout.php GET (canceled) undefined jquery.js:5763 13B 31ms
checkout.php GET (canceled) undefined jquery.js:5763 13B 21ms
checkout.php POST 302 text/html Other 542B 134ms 93ms41ms
checkout.php GET 302 text/html jquery.js:5779 541B 194ms 63ms131ms
我想要做的就是 POST 到结帐,这应该会导致重定向到登录。这里发生了什么?有什么想法吗?