请勿对多个元素使用相同的ID。使用类代替。
将代码更改为此:
<form id="form1" method="post"> <input type="text" id="name1" name="value" value=""> <input type="submit" value="Save Changes"> <!-- changed --></form><form id="form2" method="post"> <input type="text" id="name2" name="value" value=""> <input type="submit" value="Save Changes"> <!-- changed --></form><script>// this is the class of the submit button$(".update_form").click(function() { // changed $.ajax({type: "POST",url: "approve_test.php",data: $(this).parent().serialize(), // changedsuccess: function(data) { alert(data); // show response from the php script.} }); return false; // avoid to execute the actual form submission.});</script>
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)