Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/sharepoint/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript jQuery form.submit();不在Firefox中工作_Javascript_Jquery_Html_Forms - Fatal编程技术网

Javascript jQuery form.submit();不在Firefox中工作

Javascript jQuery form.submit();不在Firefox中工作,javascript,jquery,html,forms,Javascript,Jquery,Html,Forms,我已经看到一些帖子试图在firefox中使用jquery提交表单,但我无法在我的表单中使用这些解决方案 我的页面上有两个表单,我要做的是同时提交它们。我目前有第一个按钮提交表格2,当表格2提交后,再提交表格1。我必须这样做,因为我托管这些表单的地方需要页面重定向。如果两个表单都在重定向,我无法同时提交这两个表单,因此我提交表单#2,阻止重定向,然后提交表单#1 这两个表单都在Chrome和IE中完美地提交和发布数据,但我无法使用标有“form2”的表单在使用Firefox时发布数据。为什么在我使

我已经看到一些帖子试图在firefox中使用jquery提交表单,但我无法在我的表单中使用这些解决方案

我的页面上有两个表单,我要做的是同时提交它们。我目前有第一个按钮提交表格2,当表格2提交后,再提交表格1。我必须这样做,因为我托管这些表单的地方需要页面重定向。如果两个表单都在重定向,我无法同时提交这两个表单,因此我提交表单#2,阻止重定向,然后提交表单#1

这两个表单都在Chrome和IE中完美地提交和发布数据,但我无法使用标有“form2”的表单在使用Firefox时发布数据。为什么在我使用firefox时form1会发布数据而form2不会发布数据

这是我的


试试这个,我们将使用承诺:

/* create a function to submit the forms */
function formSubmit(el, url) {
    $.ajax({
      type: 'post',
      url: url,
      data: el.serialize(),
      complete: function() {}
    });
}

/* now we say, when first form has been submitted, submit the next */
$.when(formSubmit($('#form2'), 'http://myAjaxUrl2/')).then(function() {
  formSubmit($('#form1'), 'http://myAjaxUrl1/')
});

当表单2提交完成时提交表单1?这就是你的意思吗?是的,当表格2已经提交,那么表格1应该提交。我尝试在ajax complete中实现这一点,但它不起作用,所以我不得不将它从那里拉出来,放在底部,正如您所看到的,这应该是在ajax成功中实现的,很简单-如果这不起作用,您需要显示您的代码,因为这是正确的方法-除非您想使用承诺,但是我会先试试这个我已经试过了,但我不能提交任何一种形式:successs:function(){$('#form1')。submit()}任何一种形式?您在浏览器控制台中看到了什么错误?
/* create a function to submit the forms */
function formSubmit(el, url) {
    $.ajax({
      type: 'post',
      url: url,
      data: el.serialize(),
      complete: function() {}
    });
}

/* now we say, when first form has been submitted, submit the next */
$.when(formSubmit($('#form2'), 'http://myAjaxUrl2/')).then(function() {
  formSubmit($('#form1'), 'http://myAjaxUrl1/')
});