我是 Javascript 的新手——实际上是第一次对其进行编码。我正在尝试使用SweetAlert进行删除确认按钮。当我按下带有 的按钮时没有任何反应onclick="confirmDelete()"
。这段代码可能只是螃蟹,但这里是:
<script type="text/javascript">
function confirmDelete() {
swal({
title: "Are you sure?",
text: "You will not be able to recover this imaginary file!",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes, delete it!",
closeOnConfirm: false
)},
$.ajax({
url: "scriptDelete.php",
type: "POST",
data: {id: 5},
dataType: "html",
success: function () {
swal("Done!","It was succesfully deleted!","success");
}
});
}
</script>
<a href="#" onclick="confirmDelete()">Delete</a>
如果删除失败,我可以添加任何警报吗?