本次论坛没有任何案例帮助我。我做了所有引用的选项,如Ajax提交表单两次
$(this).unbind("click");
e.stopPropagation();
e.preventDefault();
return false;
$('form').unbind("submit");
onsubmit="return false;
etc...
我把那些无处不在。他们没有为我的案件工作。 Plz,帮助我,我只是坚持需要尽快启动项目。
这里是我的代码:
<form class="form-horizontal" method="post" id="payment">
<fieldset id="pincode_fieldset" <?php echo ($user->pincode=="" || $user->pincode_error==3)? "disabled":""; ?>>
<input type="text" class="form-control" id="username" name="username">
<input type="text" class="form-control" id="password" name="password">
<input type="text" class="form-control" id="deposit" name="deposit">
<a type="submit" id="submit_btn" class="btn btn-primary btn-small pull-right">Pay</a>
</fieldset>
</form>
<script>
//payment confirmation;
function confirmPayment(){
$("#username2").text($("#username").val());
$("#deposit2").text("€"+$("#deposit").val());
$('#confirmModal').modal('show');
$("#confirm_btn").click(function(e){
$("#modal_content").hide();
//$(this).unbind("click");
submitForm('#payment','payment.php', true, true);
//e.stopPropagation();
});
$("#back_btn").click(function(){
$('#confirmModal').modal('hide');
$(document).ready(function(){
$('#modal_content').show('slow');
});
});
//$('form').unbind("submit");
return false;
}
$("#payment").submit(function(){
confirmPayment();
return false;
});
</script>
案例1: 当我点击#submit_btn并单击#confirm_btn形式提交一次;
案例2: 当我点击#submit_btn并单击#back_btn并单击#submit_btn并单击#confirm_btn表单提交两次;
情况下3: ,如果我做的动作3次将其提交三次
等
我警惕地检查(); 的问题是在这里:
$("#confirm_btn").click(function(e){
$("#modal_content").hide();
//$(this).unbind("click");
submitForm('#payment','payment.php', true, true);
//e.stopPropagation();
});
submitForm()被再次提交,再次取决于我已经#submit_btn作出的点击。我需要在提交之前给用户选择确认。请帮助我,我无法解决它花费整日和夜晚。
你确实需要时才确认用户想要做什么,他们只是做了?这不就是烦人吗? – thebjorn
是的,因为用户名必须确定。否则,转账的钱不能退还。如果用户名上有错字,并且该用户名存在,钱将被错误地转移到该用户名。因此我需要用户在汇款前双重确认。 – xnote
你确定他们不确定他们是否输入了大量数据并点击了提交? (我可以继续下去,但它很快变得非常恼人..)我认为你的根本问题是'confirmPayment()'函数既能确认,提交和设置事件处理程序(有点难以分辨出发生了什么,因为你的缩进是不可靠的)。 – thebjorn