Javascript Swal2-未捕获(承诺中)类型错误:未定义

Javascript Swal2-未捕获(承诺中)类型错误:未定义,javascript,ajax,promise,undefined,sweetalert,Javascript,Ajax,Promise,Undefined,Sweetalert,请帮我调查一下。这本应该是最简单的部分,它已经让我的头脑发疯了(哈哈)。我就是搞不清楚 Ajax被一个swal承诺所包裹,并被困在这里。取消按钮确实触发swal警报,但确认按钮返回错误: “未捕获(承诺中)类型错误:未定义” 做了大量的变化,它不会消失。日志(结果)显示那里一切正常。有人请,什么是我没有看到和处理错误显然 <link href="../assets/css/sweetalert2.css" rel="stylesheet" />

请帮我调查一下。这本应该是最简单的部分,它已经让我的头脑发疯了(哈哈)。我就是搞不清楚

Ajax被一个swal承诺所包裹,并被困在这里。取消按钮确实触发swal警报,但确认按钮返回错误:

“未捕获(承诺中)类型错误:未定义”

做了大量的变化,它不会消失。日志(结果)显示那里一切正常。有人请,什么是我没有看到和处理错误显然

<link href="../assets/css/sweetalert2.css" rel="stylesheet" />
<script src="../assets/js/jquery-3.6.0.js"></script> 
<script src="../assets/js/polyfill.js"></script> 
<script src="../assets/js/sweetalert2.all.min.js"></script>


$(文档).on('click','fa trash',函数(事件){
theid=event.target.attributes['id'].value;
filename=event.target.attributes['data-filename'].value;
delrowID=event.target.attributes['data-delete'].value;
theidID=“#”+theid;
delrowID=“#”+delrowID;
$(theidID).removeClass('fa-trash')
.addClass('fa-spinner')
.addClass(“fa-spin”);
userID=$(“#userID”).val;
const swalWithBootstrapButtons=Swal.mixin({
客户类别:{
确认按钮:“btn btn成功”,
取消按钮:“btn btn危险”
},
按钮样式:false
})
带靴扣的swalWithBootstrapButtons.fire({
标题:“你确定吗?”,
html:“您将删除文件“+filename+”及其所有子文件。您将无法还原此文件!”,
图标:“警告”,
showCancelButton:true,
confirmButtonText:'是,删除它!',
cancelButtonText:'不,取消!',
反转按钮:真
})。然后((结果)=>{
控制台日志(结果);
如果(结果已确认){
$.ajax({
方法:“张贴”,
数据类型:“json”,
url:“data_auth.php?action=delete”,
数据:{
泰德:泰德,
filename:filename,
userID:userID
},
beforeSend:函数(){
喷火({
标题:“请稍候…”,
html:“正在删除”,
imageUrl:'images/delete.gif',
图像高度:200,
imageAlt:'正在删除…',
showCloseButton:false,
showCancelButton:false,
allowOutsideClick:false,
allowEscapeKey:错误
})
}
})
.done(函数(msg){
responsejson=JSON.parse(msg);
Swal.close();
responsejson.forEach(函数(元素){
响应=元素响应;
描述=元素描述;
descriptx=element.descriptionx;
})
如果(响应=“完成”){
$(delrowID).remove();
带靴扣的swalWithBootstrapButtons.fire(
描述,
“您的文件(“+filename+”)已被删除。”,
“成功”
)
返回false;
}
如果(响应==“不成功”){
带靴扣的swalWithBootstrapButtons.fire(
“请再试一次!”,
'发生错误,您的文件('+filename+')删除被中断。请重试删除',
“错误”
)
$(theidID).addClass('fa-trash')
.removeClass(“fa-spinner”)
.removeClass(“fa-spin”);
返回false;
}
});
}否则如果(
result.dismise===Swal.DismissReason.cancel
) {
带靴扣的swalWithBootstrapButtons.fire(
“删除操作已取消”,
'您的文件('+filename+')是安全的:)',
“信息”
)
$(theidID).addClass('fa-trash')
.removeClass(“fa-spinner”)
.removeClass(“fa-spin”);
返回false;
}
})
})
谢谢


    $(document).on('click', '.fa-trash', function (event) {

        theid = event.target.attributes['id'].value;
        filename = event.target.attributes['data-filename'].value;
        delrowID = event.target.attributes['data-delete'].value;
        theidID = "#" + theid;
        delrowID = "#" + delrowID;

        $(theidID).removeClass('fa-trash')
            .addClass('fa-spinner')
            .addClass('fa-spin');


        userID = $("#userID").val;

        const swalWithBootstrapButtons = Swal.mixin({
            customClass: {
                confirmButton: 'btn btn-success',
                cancelButton: 'btn btn-danger'
            },
            buttonsStyling: false
        })

        swalWithBootstrapButtons.fire({
            title: 'Are you sure?',
            html: "You are about to <strong> delete the file " + filename + " and all its sub-files. </strong> You won't be able to revert this!",
            icon: 'warning',
            showCancelButton: true,
            confirmButtonText: 'Yes, delete it!',
            cancelButtonText: 'No, cancel!',
            reverseButtons: true
        }).then((result) => {
            console.log(result);
            if (result.isConfirmed) {


                $.ajax({
                        method: "POST",
                        dataType: "json",
                        url: "data_auth.php?action=delete",
                        data: {
                            theid: theid,
                            filename: filename,
                            userID: userID
                        },

                        beforeSend: function () {
                            Swal.fire({
                                title: '<strong>Please Wait...</strong>',
                                html: '<h3>Deleting in progress</h3>',
                                imageUrl: 'images/delete.gif',
                                imageHeight: 200,
                                imageAlt: 'deleting...',
                                showCloseButton: false,
                                showCancelButton: false,

                                allowOutsideClick: false,
                                allowEscapeKey: false
                            })
                        }
                    })
                    .done(function (msg) {

                        responsejson = JSON.parse(msg);

                        Swal.close();

                        responsejson.forEach(function (element) {

                            theresponse = element.response;
                            thedescript = element.description;
                            thedescriptx = element.descriptionx;


                        })


                        if (theresponse == "done") {


                            $(delrowID).remove();


                            swalWithBootstrapButtons.fire(
                                thedescript,
                                'Your file (' + filename + ')  has been deleted.',
                                'success'
                            )
                            return false;
                        }

                        if (theresponse == "nosuccess") {
                            swalWithBootstrapButtons.fire(
                                'Please try again!',
                                'An error occured and your file (' + filename + ') deletion was interrupted. Try Delete Again',
                                'error'
                            )

                            $(theidID).addClass('fa-trash')
                                .removeClass('fa-spinner')
                                .removeClass('fa-spin');
                            return false;
                        }


                    });


            } else if (
                
                result.dismiss === Swal.DismissReason.cancel
            ) {
                swalWithBootstrapButtons.fire(
                    'Delete Action Cancelled',
                    'Your file (' + filename + ') is safe :)',
                    'info'
                )
                $(theidID).addClass('fa-trash')
                    .removeClass('fa-spinner')
                    .removeClass('fa-spin');
                return false;
            }
        })

    })