<?php
print_r($_REQUEST);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery AJAX Submit Form</title>
<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
</head>
<body>
<form id="form1" method="post">
<input type="text" id="name[1]" name="value" value="aaa">
<input type="submit" class="update_form" value="Update">
</form>
<form id="form2" method="post">
<input type="text" id="name[2]" name="value" value="bbb">
<input type="submit" class="update_form" value="Update">
</form>
<script>
// class of the submit button
$(".update_form").click(function() {
$.ajax({
type: "POST",
url: "",
data: $(this).parent().serialize(),
success: function(data) {
alert(data); // show response from php script.
}
});
return false; // avoid to execute actual form submission.
});
</script>
</body>
</html>