首页 文章

PHP Sweet Alert页面重定向

提问于
浏览
0

我使用AJAX使用Sweet Alert进行删除,并在删除后设置了页面重定向 . 每当我点击删除时,它会询问是否确认按钮,如果我单击是 - 确认它将删除,并且页面被重定向 . 我想要删除成功消息后“确定已成功删除”那个时间只有页面被刷新,

function delete_confirm(id) {
            swal({
                    title: "Are you sure?",
                    text: "You will not be able to recover this Product Attribute!",
                    type: "warning",
                    showCancelButton: true,
                    confirmButtonColor: '#DD6B55',
                    confirmButtonText: 'Yes, delete it!',
                    cancelButtonText: "No, cancel please!",
                    closeOnConfirm: false,
                    closeOnCancel: false
                },
                function(isConfirm) {
                    if (isConfirm) {
                        $.ajax({
                            url: "cart-delete.php",
                            type: "POST",
                            data: {
                                id: id,
                            },
                            success: function(data) {
                                console.log(data); 
                                swal("Done!", "It was succesfully deleted!", "success");
                                $('[remove_attr_' + id + ']').parents('.demo-card-wide').remove();
                                  window.location.href = 'add-to-cart.php';
                            }
                        });
                    } else {
                        swal("Cancelled", "Your Product Attribute! is safe :)", "error");
                    }
                });
        };

1 回答

  • 1

    删除此行成功

    window.location.href = 'add-to-cart.php';
    

    写一些其他行动ex . 在甜蜜警报关闭行动

相关问题