jQuery   发布时间:2022-03-30  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了使用一个提交按钮jQuery提交两个表单大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我已经尝试了多种方法,通过在stackoverflow上搜索答案.

我有两种形式

表格1基本设置:

<form action="/post" class="frm-form"  method="post" name="post" 
onsubmit="return vB_Editior['text_editor'].prepare_submit(0,0)" id="quick_reply">
   <textarea></textarea>
      <input type="submit" name="post" value="Send">
</form>

表2基本设置:

<form enctype="multipart/form-data" id="tagnotif" style="display:none;" 
onsubmit="return vB_Editor['text_editor'].prepare_submit(0,0)" name="post2" 
method="post" action="/privmsg">
   <input id="username" class="post" type="text" tabindex="1" size="25" 
       name="username[]"style="margin:1px 0"><br />
   <input id="acpro_inp10" class="post" type="text" 
     onkeypress="if (event.keyCode==13){return false}" title="" tabindex="2" 
    maxlength="64" size="45" value="You have been tagged" name="subject"><br />
  <textarea id="textingnotification" rows="15" cols="9"
   name="message" tabindex="3"></textarea>
   <input type="hidden" value="" name="lt">
     <input type="hidden" value="inBox" name="folder">
       <input type="hidden" value="post" name="mode">
</form>

我只需要在SEND印刷机上提交这两个表格

尝试使用主要脚本使用此代码变量:虽然它不会同时通过,但它不会刷新页面

$(document).ready(function() { 
    $('#quick_reply').ajaxForm(function() { 
            alert("Thank you for your submitting form 1"); 
    });
    $('#tagnotif').ajaxForm(function() { 
            alert("Thank you for your submitting form 2"); 
    });

}); 

function mySubmitFunction() {
    $("#quick_reply").submit();
    $("#tagnotif").submit();
}
@H_403_32@解决方法
我不认为您可以从单个html页面执行两个常规发布请求,因为发布帖子涉及离开页面并遵循重定向响应.

如果您通过ajax提交表单,为什么不只是制作一个ajax按钮并获取所需的参数以坚持请求? IE:

$.ajax({
  type: 'POST',dataType: 'JSON',data: {param1: $('input#param1').val(),param2: $('input#param2').val()},url: 'url to post to',success: (your success callback function goes here)
})

大佬总结

以上是大佬教程为你收集整理的使用一个提交按钮jQuery提交两个表单全部内容,希望文章能够帮你解决使用一个提交按钮jQuery提交两个表单所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签: