📌  相关文章
📜  sweetalert2 删除确认站点:stackoverflow.com - 任何代码示例

📅  最后修改于: 2022-03-11 14:57:50.692000             🧑  作者: Mango

代码示例2
function hapus($___id) {  
  swal.fire({
        title: 'Are you sure?',
        text: "Are you sure you want to proceed ?",
        type: 'warning',
        showCancelButton: true,
        confirmButtonText: 'Yes'
    }).then(function(result) { 
        if (result.value) {
            $.ajax({
                url : `postingan/hapus/${$___id}`,
                type : 'GET',
                dataType:'json',
                beforeSend: function() {
                    swal.fire({
                        title: 'Please Wait..!',
                        text: 'Is working..',
                        onOpen: function() {
                            swal.showLoading()
                        }
                    })
                },
                success : function(data) { 
                    swal.fire({
                        position: 'top-right',
                        type: 'success',
                        title: 'User  deleted successfully',
                        showConfirmButton: false,
                        timer: 2000
                    });
                 },
                complete: function() {
                    swal.hideLoading();
                },
                error: function(jqXHR, textStatus, errorThrown) {
                    swal.hideLoading();
                    swal.fire("!Opps ", "Something went wrong, try again later", "error");
                }
            });
        }
    });
}