【发布时间】:2012-10-30 15:54:53
【问题描述】:
我使用下面的代码提交我的表单而不重新加载页面,但是当AJAX成功部分的data.a="a"或"b"等时,我仍然想提交表单为通常由没有 jQuery 的 php 完成。
所以在这种情况下,目的是将 AJAX 数据(“data:myForm.serialize()+”&id_town="+id_town,")传输到表单的“action”html 属性中指定的 url。
你有什么想法吗?
HTML代码:
<form id="inscription_form_home" action="index.php?module=membres&action=inscription" method="post" >
...
</form>
jQuery 代码:
$("#inscription_form_home").submit(function() {
var myForm = $(this);
$.ajax({
dataType: 'json',
type: "POST",
url: "traitement_profil.php",
data:myForm.serialize()+"&id_town="+id_town,
success: function(data){
if (data.a == "a" || data.a == "b" ){
// Transmit the data part to the form url
}else{
alert("Inscription OK.");
}
}
});
return false;
});
【问题讨论】:
-
你问如何对
actionurl 进行第二次ajax 调用? -
解释得很差,看不懂你想要什么
-
@charlietfl :是的,我认为这可能是解决方案。我们该怎么做?
-
需要清晰简洁的重定向顺序。忘记代码..在问题主体中解释行为开始到结束
-
好的,我刚刚编辑了我的问题。