当我不使用 jquery 的警报插件时,我得到了这个完美的脚本。但我需要使用警报插件,在从教程中学习后,我实现了它。但是脚本似乎不起作用。
<script type = "text/javascript">
$(document).ready(function() {
var pos = $("tr.verify").attr('id');
var frmId = $('#'+ pos).find("form").attr('id');
$('#'+ frmId).click(function(event) {
jConfirm('Are you sure you want to verify?', 'Confirmation Dialog',
function(r) {
if(r==true)
{
$.ajax({
type: "POST",
url: "verify.php",
data: $("form#" + frmId).serialize(),
success: function(msg){
if(msg.indexOf("success") > -1)
{
//success in registaration
var inputsub = $("form#" + frmId).find('input[type=submit]').attr('id');
$('#' + inputsub).val('verified').attr('disabled','disabled');
} //end of if
else if(msg.indexOf("Error") > -1)
{
alert(msg);
} //end of else if
} // end of success event
}); //end of ajax code
} // end of if r == true
return false;
}); //the alert code
}); //end of form submit
}); //Main document ready code
</script>