jquery的表单提交不在IE中工作
我们在这里要做的是我们有一个id为upgrade_form的表单。我们还有一个名为paypal_submit的表单。此表格为空白。 'upgrade_form'有结算明细字段(地址,姓名,到期等)
What we are trying to do here is that we have a form with an id of upgrade_form. We also have a form called 'paypal_submit' form. This form is blank. 'upgrade_form' has billing detail fields(address, name, expiry etc)
我们只有一个提交按钮,逻辑是它将提交表格,如果信用卡单选按钮被选中,但它会显示一个nyromodal( http://nyromodal.nyrodev.com )当您选择paypal单选按钮并单击提交时,灯箱。
We then have just one submit button, and the logic was that it will submit the form if a credit card radio button is checked, but it will show a nyromodal(http://nyromodal.nyrodev.com) lightbox when you choose the paypal radio button and click submit.
- 编辑*
好的,我们彻底改变了整个过程。我们首先添加了2个未包含在表单中的隐藏字段。这两个字段包含信用卡和贝宝的网址。当您选择信用卡单选按钮时,您将获得信用卡网址。当您选择paypal单选按钮时,您将获得PayPal网址。
Okay, we totally revamped the whole process. We first added 2 hidden fields that are not included in the form. These 2 fields contain urls for credit card and paypal. When you select the credit card radio button, you get the credit card url. When you select the paypal radio button, you get the paypal url.
当您单击单选按钮时,我们会使用以下内容更改表单的操作:
When you click on the radio button, we change the action of the form with this:
$('#upgrade_form').attr('action', $('#credit-card-target-url').val())
(credit-card-url是隐藏字段)
(credit-card-url is the hidden field)
因此,当我们点击nyromodal灯箱中的链接时,我们只需拨打
So when we click on the link in the nyromodal lightbox, we just call
$('#upgrade_form').submit();
但是!它仍然不适用于任何IE浏览器。对此有何帮助?我们正在安装建议的IE脚本调试器,但我很悲观,我们什么都看不到。
BUT! IT STILL DOESN'T WORK IN ANY IE. Any help on this? We're in the process of installing the suggested IE script debugger but I'm pessimistic we won't see anything.
EDIT
重试这个。我们拿出了灯箱和其他代码。我们刚刚开始使用一个带有链接的基本表单,按下时,调用:
Just retried this one. We took out the lightbox, and the other code. We just started with a basic form with a link that when pressed, calls:
$('#upgrade_form').submit();
仍然无法在IE中运行。那是因为jquery的submit()吗?
Still doesn't work in IE. So is it because of the submit() of jquery?
好的我用google搜索jquery提交不在IE中工作并发现: jQuery表单提交()在IE6中不起作用?
Okay I googled for jquery submit not working in IE and found this: jQuery form submit() is not working in IE6?
但是我检查了我们的代码和我们的代码'submit'按钮实际上是一个链接,我搜索了生成的文档,发现没有名为submit的输入。单击链接时,我添加了一个警报来检查表单是否存在(由于nodeName null问题),我确实收到了带有html格式的警报。它只是暂停提交。
But I checked our code and our 'submit' button is actually a link, and I searched the generated docment and found no inputs named submit. When the link is clicked, I added an alert to check if the form exists(because of the nodeName null problem) and I do get the alert with the form html. It just halts at submit.
这里是代码:
$('#paypalbutton').click( function() {
alert($('form#upgrade_form').html());
$('form#upgrade_form').submit();
return true;
}
IE停止此行jquery:
IE halts on this line in jquery:
nodeName: function( elem, name ) {
return elem.nodeName && elem.nodeName.toUpperCase() === name.toUpperCase();
},
我最近有一个类似的问题,我在ASP.NET服务器表单中创建一个伪表单(所以我不能使用另一个表单标签),我想发布到另一个域而无需编写服务器端代码来执行远程发布。轻松回答 - 动态创建表单并提交。在良好的浏览器中工作...
I've recently had a similar issue, where I was creating a "pseudo-form" within an ASP.NET server form (so I couldn't use another form tag), which I wanted to post to another domain without needing to write server-side code to do the remote post. Easy answer - create a form on the fly and submit it. Works in good browsers...
经过一些考验和磨难后,我意识到IE将无法按预期工作(这太令人惊讶了e)除非已提交的表单已添加到DOM。所以,这是我的解决方案。我希望它可以帮助你们中的一些人。请注意,我的所有输入和提交都在同一个容器中。 .post-to是带有URL的隐藏输入。
After some trials and tribulations, I realised that IE won't work as expected (what a surprise) unless the form that is being submitted has been added to DOM. So, this was my solution. I hope it helps some of you. Please be aware, all of my inputs and my submit were in the same container. ".post-to" is a hidden input with the URL.
$(".post-form").click(function(ev) {
var postto = $(this).siblings(".post-to").val();
var form = document.createElement("form")
$(form).attr("id", "reg-form").attr("name", "reg-form").attr("action", postto).attr("method", "post").attr("enctype", "multipart/form-data");
$(this).siblings("input:text").each(function() {
$(form).append($(this).clone());
});
document.body.appendChild(form);
form.submit();
document.body.removeChild(form);
return false;
});
最终,这是一种享受。