Serialize multiple forms together?

后端 未结 3 1807
-上瘾入骨i
-上瘾入骨i 2020-12-04 16:24

Can you serialize multiple forms into one so that only one post or ajax request is made? I have searched around and it is all for submiting each form separently via post/aja

3条回答
  •  孤城傲影
    2020-12-04 17:24

    When you use the jQuery serialize() function, it simply turns your form into a string in the format a=1&b=2&c=3. So you can certainly apply this function to two forms and concatenate the result, with an & between them, and use the result in your ajax call. You'd want some checks to make sure neither string is empty when you do the concatenation.

提交回复
热议问题