<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