定位要通过Ajax发送的多种表单(jquery)

定位要通过Ajax发送的多种表单(jquery),第1张

定位要通过Ajax发送的多种表单(jquery)

请勿对多个元素使用相同的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>


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/5016316.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-11-15
下一篇 2022-11-14

发表评论

登录后才能评论

评论列表(0条)

保存