Targeting multiple forms to send via ajax (jquery)

前端 未结 5 719
暖寄归人
暖寄归人 2020-12-03 16:17

I have multiple forms on my page. When I click the forms submit button, I want to send the form value of only that form through ajax. Here is what I have. The first form w

5条回答
  •  难免孤独
    2020-12-03 16:41

    Try the following:

    var form = $('#form1', '#form2').serialize();
    $.ajax({
        type: "POST",
        url: "approve_test.php",
        data: form,
        success: function(data) {
            alert(data); // show response from the php script.
        }
    });
    

提交回复
热议问题