【发布时间】:2014-07-21 11:27:24
【问题描述】:
我如何将帖子从一个表单发送到 2 个不同的网址
喜欢同时向process.php和confirm.php发送POST名称
$(document).ready(function(){
$("#myform").validate({
debug: false,
rules: {
name: "required",
email: {
required: true,
email: true
}
},
messages: {
name: "Please let us know who you are.",
email: "A valid email will help us get in touch with you.",
},
submitHandler: function(form) {
// do other stuff for a valid form
$.post('process.php', $("#myform").serialize(), function(data) {
$('#results').html(data);
});
}
});
});`
还有我的表格
<form name="myform" id="myform" action="confirm.php" method="POST">
<label for="name" id="name_label">Name</label>
<input type="text" name="name" id="name" size="30" value=""/>
<br>
<label for="email" id="email_label">Email</label>
<input type="text" name="email" id="email" size="30" value=""/>
<br>
<input type="submit" name="submit" value="Submit">
感谢您的帮助
【问题讨论】:
-
只有在取消表单的正常提交并通过 AJAX 发出这两个请求时才能这样做。但无论如何,在大多数情况下,当人们提出这样的问题时,他们已经走错了路 - 所以请先在此处描述您真正想要实现的目标。
标签: javascript php ajax arrays forms