閱讀813 返回首頁    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 命令