阅读813 返回首页    go 阿里云 go 技术社区[云栖]


jQuery点击一次按钮提交多个表单带来的问题

 

第一种情况

<html>

    <body>

             <form action="a.action" method="post"></form>

            <form action="b.action" method="post"></form>

           <input type="button" value="提交"/>

    </body>

</html>

 

$("#btn").click(function(){

        $("#aForm").submit();

        $("#bForm").submit();

});

 

结论

完全没有问题。两次提交行为本身就是独立的。

 

 

第二种情况

<html>

    <body>

             <form action="a.action!aMethod" method="post">

                     <input name="aValue" />   

            </form>

            <form action="a.action!bMehtod" method="post"></form>

           <input type="button" value="提交"/>

    </body>

</html>

 

public class aaction extends ActionSupport

{

       private String aValue;

          public String aMethod(){}

          public String bMethod(){

                   String a = aValue;  (错误:因为两次表单提交是独立的,各提交行为数据无法共享)

         }

}

 

结论

因为两次表单提交是独立的,各提交行为数据无法共享。

 

 

 

最后更新:2017-04-02 16:48:03

  上一篇:go 语言堆栈入门——堆和栈的区别
  下一篇:go android 命令