SweetAlert2实践代码

来源:互联网 发布:网络借贷办法 编辑:程序博客网 时间:2024/06/01 23:15
<script>        $(function () {            $('#a-del').click(function () {                swal({                    text: "确定要删除?",                    type: 'warning',                    showCancelButton: true,                    confirmButtonColor: '#ff0000',                    cancelButtonText: '取消',                    cancelButtonColor: '#4cd964',                    confirmButtonText: '删除',                }).then(function (isConfirm) {                    if (isConfirm) {                        $.get({                            url: '/CMS/delbook/',                            data: {                                val: $('#a-del').parent().prev().text()                            },                            success: function (data) {                                if (data) {                                    $('#a-del').parent().parent().remove();                                }                            }                        });                        swal({                                text: "删除成功",                                type: 'success',                                showCancelButton: false,                                showConfirmButton: false                            }                        );                        setTimeout(function () {                            window.location.href = 'http://127.0.0.1:8000/CMS/bkmgr.html';                        }, 2000)                    }                }, function (dismiss) {                    if (dismiss === 'cancel') {                        swal(                            '取消',                            '',                            'error'                        )                    }                })            })        })    </script>
原创粉丝点击