简体   繁体   English

jQuery表单创建未在IE中提交

[英]Jquery form creation not submitting in IE

I'm hosting a simple test page at http://ss.amityregion5.org/crypto.php . 我在http://ss.amityregion5.org/crypto.php上托管了一个简单的测试页。

It's simply testing RSA encryption: Client Jquery, upon hitting the submit button, encrypts the message with the server's public key (visible in javascript). 它只是在测试RSA加密:单击“提交”按钮后,客户端Jquery使用服务器的公共密钥(在javascript中可见)对消息进行加密。 This encrypted value is sent to the server, which decrypts the message with its own private key. 该加密值被发送到服务器,服务器使用其自己的私钥对消息解密。

This code runs perfectly fine in Chrome and Safari. 这段代码在Chrome和Safari中运行良好。 However in Internet Explorer (11), the form fails to submit. 但是,在Internet Explorer(11)中,表单无法提交。 Interestingly, however, the Developer Console never spits out an error, so I'm at a loss as to what the issue is. 但是,有趣的是,开发者控制台从不吐出一个错误,所以我对问题所在不知所措。 I may just be missing something stupid, or IE could be doing something funky with JS parsing. 我可能只是想念一些愚蠢的东西,或者IE可能通过JS解析来做一些时髦的事情。

From my incremental testing, I suspect the issue might be the last line of my javascript, where I create a hidden form element, fill it with the ciphertext, and submit it. 从我的增量测试中,我怀疑问题可能出在我的JavaScript的最后一行,我在其中创建了一个隐藏的form元素,并用密文填充并提交了它。 Is this behavior not supported on IE, and if not, how may I fix it. IE不支持此行为吗?如果不支持,我该如何解决。

Thanks in advance. 提前致谢。

You need to append the form to the document before you submit it. 您需要先将表格添加到文档中,然后再提交。

$('<form method="post"><input type="hidden" name="message" value="' + ciphertext + '"></form>')
    .appendTo("body")
    .submit();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM