내 코드에 SweetAlert2를 구현하려고 시도했습니다. 트리거 버튼에서 함수를 호출하지 못했습니다.Sweetalert AJAX 실패
이 코드를 수정하려면 어떻게해야합니까?
$(".delete").click(function() {
swal({
title: 'Are you sure?',
text: "You won't be able to revert this!",
type: 'warning',
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonText: 'Yes, delete it!'
}).then(function() {
delete_post($(this).attr("id"));
swal(
'Deleted!',
'Your file has been deleted.',
'success'
)
})
})
});
호출 된 함수 : 다음이 행하기 전에
function delete_post(id) {
var info = {"delete_post_id":id};
$.post('index.php',
info
).done(function(response) {
if(response["error"]) {
$('#error').html(response["error"]);
}else{
window.location = "index.php";
}
});
}
delete_post가 호출되지 않았습니까? – CaptainHere
예 그냥 삭제를 건너 뜁니다 @ILikeToMoveItMoveIt –
응답 내용은 무엇입니까? 성공, swal() 전에 delete_post를 호출하십시오. 또한, 누락 된 세미 콜론에서 내 눈이 타 오릅니다! – cnorthfield