Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/439.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 显示甜蜜警报对话框时出错_Javascript_Jquery_Sweetalert - Fatal编程技术网

Javascript 显示甜蜜警报对话框时出错

Javascript 显示甜蜜警报对话框时出错,javascript,jquery,sweetalert,Javascript,Jquery,Sweetalert,我正试图利用图书馆发出警报。 我曾尝试集成代码,以发出删除项目的确认警报,但当我单击删除项目的按钮时,这些代码不起作用。该对话框不显示 集成甜蜜警报之前的代码: $(".delete-link").click(function() { var id = $(this).attr("id"); var del_id = id; var parent = $(this).parent("td").parent("tr"); if (confirm('Sure to D

我正试图利用图书馆发出警报。 我曾尝试集成代码,以发出删除项目的确认警报,但当我单击删除项目的按钮时,这些代码不起作用。该对话框不显示

集成甜蜜警报之前的代码

$(".delete-link").click(function() {
    var id = $(this).attr("id");
    var del_id = id;
    var parent = $(this).parent("td").parent("tr");
    if (confirm('Sure to Delete ID no = ' + del_id)) {
        $.post('delete.php', { 'del_id': del_id }, function(data) {
            parent.fadeOut('slow');
        });
    }
    return false;
});
    $(".delete-link").click(function() {
        var id = $(this).attr("id");
        var del_id = id;
        var parent = $(this).parent("td").parent("tr");
    });

    swal({
            title: "Are you sure you want to delete?",
            text: "Sure to Delete ID no = " + del_id,
            type: "warning",
            showCancelButton: true,
            confirmButtonColor: "#DD6B55",
            confirmButtonText: "Yes",
            closeOnConfirm: false
        },
        function() {
            $.post('delete.php', { 'del_id': del_id }, function(data) {
                parent.fadeOut('slow');
            });
        });
    return false;

});
集成甜警报后的代码

$(".delete-link").click(function() {
    var id = $(this).attr("id");
    var del_id = id;
    var parent = $(this).parent("td").parent("tr");
    if (confirm('Sure to Delete ID no = ' + del_id)) {
        $.post('delete.php', { 'del_id': del_id }, function(data) {
            parent.fadeOut('slow');
        });
    }
    return false;
});
    $(".delete-link").click(function() {
        var id = $(this).attr("id");
        var del_id = id;
        var parent = $(this).parent("td").parent("tr");
    });

    swal({
            title: "Are you sure you want to delete?",
            text: "Sure to Delete ID no = " + del_id,
            type: "warning",
            showCancelButton: true,
            confirmButtonColor: "#DD6B55",
            confirmButtonText: "Yes",
            closeOnConfirm: false
        },
        function() {
            $.post('delete.php', { 'del_id': del_id }, function(data) {
                parent.fadeOut('slow');
            });
        });
    return false;

});

我认为你的代码中有语法错误。试试这个,看看它是否有效[我还没有测试我这边的代码]。如果不起作用,请告诉我

$(".delete-link").click(function() {
var id = $(this).attr("id");
var del_id = id;
var parent = $(this).parent("td").parent("tr");

swal({
    title: "Are you sure you want to delete?",
    text: "Sure to Delete ID no = " + del_id,
    type: "warning",
    showCancelButton: true,
    confirmButtonColor: "#DD6B55",
    confirmButtonText: "Yes",
    cancelButtonText: "No",
    closeOnConfirm: true,
    closeOnCancel: true
}, function(isConfirm) {
    $.post('delete.php', {'del_id':del_id}, function(data) {
        parent.fadeOut('slow');
    });
});
return false;
});

您在控制台中是否有任何错误?不,我认为代码有问题,但我现在不知道在哪里