<script LANGUAGE="JavaScript">
function confirmSubmit() {
jConfirm('Is the Appointment Confirmed?', 'Confirmation Dialog', function(r) {
if(r) {
return true;
} else {
return false;
}
});
}
</script>
<form name='cancel_form'id='cancel_form' method='POST' action="">
<center>
<input type='submit' name='confirm_appointment' value='Cancel Appointment' onclick='return confirmSubmit();'>
</center>
</form>
<script type='text/javascript'>
var ajax_load = "<img class='loading' src='img/load.gif' alt='loading...' />";
var saveUrl = "<?php echo $this->url(array('controller' => 'appointment', 'action' =>'cancelsave'));?>";
$('#cancel_form').ajaxForm({ success: saveCallbk , url : saveUrl });
function saveCallbk(responseText) {
jAlert(responseText,'Alert Dialog');
if(responseText.indexOf("ERROR")<0) {
$(location).attr('href',redirectUrl);
}
}
</script>
当我提交表单时,我调用这个函数并使用jQuery的jConfirm
。我打印r
。它的打印正确(例如,true
和false
),但return false
或return true
没有任何影响 - 它只显示弹出窗口并提交表单,不等待确认。如何解决这个问题?jquery返回false形式
ajaxForm插件负责本身的提交,它需要一个提交按钮。如果我使用:
function confirmSubmit() {
var agree=confirm("Is the Appointment Cancelled?");
if (agree) {
return true;
} else {
return false;
}
}
喜欢默认的JavaScript效果很好
你可以在你使用这个函数的地方包含代码吗?另外,请查看http://stackoverflow.com/editing-help,了解如何在问题中设置代码格式。 – 2010-04-07 18:22:00