使用SweetAlert时,我无法使用任何jQuery。
在下面的小提琴中,我想隐藏成功的盒子div。
我错过了一些明显的东西吗?
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
}, function (isConfirm) {
if (!isConfirm) return;
$.ajax({
url: "scriptDelete.php",
type: "POST",
data: {
id: 5
},
dataType: "html",
success: function () {
swal("Done!", "It was succesfully deleted!", "success");
$('#box').hide();
},
error: function (xhr, ajaxOptions, thrownError) {
swal("Error deleting!", "Please try again", "error");
}
});
});
}
答案 0 :(得分:0)
这不起作用的原因是因为第一个JS函数上的URL无效而且它进入了错误块而没有实际调用成功块中的hide函数。