简体   繁体   English

[0].submit 不适用于 IE 和 Firefox,在 Chrome 中完美运行

[英][0].submit not working in IE and Firefox, works perfect in Chrome

So this is the piece of script which gives me problems所以这是一段给我带来问题的脚本

function creditcard(){

var finaltotalprice = document.getElementById('finaltotalprice').innerHTML;
var total = document.getElementById('sahakol').innerHTML;
var fullprice = $('#fullprice').html();
   var phpval = parseFloat($('#cart-products-total').html());
   var name = $('#c_name').val();
   var city = $('#c_city').val();
   var add = $('#c_add').val();
   var phone = $('#c_phone').val();
   var email = $('#c_email').val();
   if(name  == '' || city == '' || add == '' || phone == ''){
   alert('נא וודאו כי מילאתם את כל שדות המשתמש');
   return false;
   } else {

   $('<form action="payment.php" method="POST"/>')
   .html( '<textarea name="total">' + total + '</textarea><textarea name="finaltotalprice">'+ finaltotalprice + '</textarea><textarea name="fullprice">' + fullprice + '</textarea> <textarea name="name">' + name + '</textarea> <textarea name="city">' + city + '</textarea> <textarea name="add">' + add + '</textarea> <textarea name="phone">' + phone + '</textarea> <textarea name="email">' + email + '</textarea> <textarea name="phpval">' + phpval + '</textarea>' )

   [0].submit();


   }}

This piece works exellent in google chrome, but broken in IE and firefox.这篇文章在谷歌浏览器中运行良好,但在 IE 和 firefox 中损坏。 The script should POST all the var's in the script to 'payment.php' and redirect the user to 'payment.php', but it doesnt redirects the user in IE and in FF.该脚本应该将脚本中的所有变量发布到“payment.php”并将用户重定向到“payment.php”,但它不会在 IE 和 FF 中重定向用户。 Any ideas?有任何想法吗?

As Pointy mentioned: I've needed to add the form to the DOM.正如 Pointy 提到的:我需要将表单添加到 DOM。 by adding通过添加

.css("display", "none").appendTo("body") 

before .submit(), now it works flawless.在 .submit() 之前,现在它完美无缺。

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

相关问题 Ajax提交可在Chrome / Safari中运行,但不能在Firefox / IE中运行 - Ajax submit works in Chrome/Safari but not Firefox/IE 提交按钮可在Chrome中使用,但不能在Firefox或IE中使用 - Submit button working in Chrome but not Firefox or IE .unbind(&#39;submit&#39;)。submit()在Chrome / IE中有效,但在Firefox中无效 - .unbind('submit').submit() works in Chrome/IE but doesn't work in Firefox Javascript / AJAX无法在Opera中运行,在FF / IE / Chrome中可以完美运行 - Javascript/AJAX not working in Opera, works perfect in FF/IE/Chrome JS 在 IE 上无法正常运行,但在 Chrome 中运行完美 - JS isn't working correctly on IE but works perfect in Chrome 选项卡式内容在Chrome和Firefox中不起作用,但在IE中可用 - tabbed content not working in Chrome and Firefox but works in IE JavaScript函数不适用于Chrome和IE,但适用于FireFox - JavaScript function not working on Chrome & IE but works on FireFox 验证不适用于Firefox,但适用于IE,Chrome - validation not working in Firefox but works in IE,Chrome JavaScript无法在IE和Firefox中运行,在Chrome中运行良好 - JavaScript not working in IE and Firefox, works fine in Chrome JavaScript 在 Firefox、Chrome 中不起作用 - 在 IE、Edge 中有效 - JavaScript not working in Firefox, Chrome - works in IE, Edge
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM