我想显示消息,该消息成功使用Sweetalert和脚本开头删除数据:
<a href="delete.php?&id=<?php echo $r['id']; ?>" class="delete-link">Delete</a>
JavaScript:
jQuery(document).ready(function($) {
$('.delete-link').on('click', function() {
var getLink = $(this).attr('href');
swal({
title: 'Alert',
text: 'Delete?',
html: true,
confirmButtonColor: '#d9534f',
showCancelButton: true,
}, function() {
window.location.href = getLink
});
return false;
});
});
数据已成功删除,但是您要显示数据消息的方式已被删除,它放在哪里?
swal("Success!", "Successfully Deleted Data!", "success");
请帮助。 谢谢。
答案 0 :(得分:0)
这是甜蜜警报的代码。
jQuery(document).ready(function($){
$('.delete-link').on('click',function(){
var getLink = $(this).attr('href');
swal({
title: "Are you sure?",
text: "You will not be able to recover this imaginary file!",
type: "warning",
showCancelButton: true,
confirmButtonClass: "btn-danger",
confirmButtonText: "Yes, delete it!",
cancelButtonText: "No, cancel plx!",
closeOnConfirm: false,
closeOnCancel: false
},
function(isConfirm) {
if (isConfirm) {
$.ajax({
url: getLink,
type: 'GET',
dataType: 'html'
})
.done(function(data){
console.log(data);
swal("Deleted!", "Your imaginary file has been deleted.", "success");
})
.fail(function(){
swal("Deleted_Error", "Error while deleting. :)", "error");
});
} else {
swal("Cancelled", "Your imaginary file is safe :)", "error");
}
});
});
});