The swal stays that way infinetly 我是javascript的新手。我正在使用swal来确认删除订单。从数据库中正确删除订单,当我重新加载页面时,我发现订单已删除,但事实是页面没有自动重新加载。
players.map((degisken) => {
const id = degisken && degisken.get('id');
if(id && id.hasOwnProperty('_tail') && id._tail.array[i] === id){
return i
}
});
并且delete.php就在这里
echo ($paid == 0) ? "<td><p data-placement='top' data-toggle='tooltip' title='Delete'><a href='#' class='btn btn-danger btn-xs delete-confirm' id='" . $orderId . "'><span class='glyphicon glyphicon-trash'></span></p></td>" : "<td></td>";
<script type="text/javascript">
$('.delete-confirm').on('click', function() {
var orderId = $(this).attr('id');
console.log(orderId);
swal({
title: "Are you sure?",
text: "If you delete this post all associated comments also deleted permanently.",
type: "warning",
showCancelButton: true,
closeOnConfirm: false,
showLoaderOnConfirm: true,
confirmButtonClass: "btn-danger",
confirmButtonText: "Yes, delete it!",
}, function() {
setTimeout(function() {
$.post("delete.php", {
id: orderId
},
function(data, status) {
swal({
title: "Deleted!",
text: "Your post has been deleted.",
type: "success"
},
function() {
location.reload();
}
);
}
);
}, 50);
});
});
</script>
<script src="js/sweetalert.min.js"></script>
&GT;
订单从数据库中成功删除,即使我等待无限时间并且页面没有重新加载,swal也不会关闭。 请帮帮我。
答案 0 :(得分:0)
你使用哪个版本的swal?
你为什么要使用setTimeout,还等什么呢?
我还以下列方式使用swal作为删除确认:
swal({
title: "Are you sure?",
text: "If you delete this post all associated comments also deleted permanently.",
type: 'warning',
showCancelButton: true,
showCloseButton: true,
reverseButtons: true,
focusCancel: true,
confirmButtonText: "Yes, delete it!",
cancelButtonText: "cancel"
})
.then( function (willDelete) {
if (willDelete) {
$.post( "delete.php",
{ id: orderId },
function(data, status) {
swal({
title: "Deleted!",
text: "Your post has been deleted.",
type: "success"
};
}
)
} else {
toastr.info(Texxt('delet canceled), Texxt('Abbruch') + '.', {
closeButton: true,
progressBar: true,
});
}
}).catch(swal.noop);