Submit two HTML forms in JSP using single submit button with Ajax

前端 未结 3 1152
忘掉有多难
忘掉有多难 2021-01-15 06:20

My page design is such that I have to use two forms that submit on single click and then saved to database and vice verse. I am using this on a JSP page with Struts2 Framewo

3条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-15 07:04

    You can use jQuery .serialize to do what you want. Give some class to your forms then use it to select your forms and call serialize to get a string in the standard URL-encoded notation. After that you can use some AJAX method to post it to your action.

    $(function() {
      $("#saveNoteButton").click(function() {
        alert($(".forms").serialize());
      });
    });
    

提交回复
热议问题