Didn"t forge 2017-12-16 10:54 采纳率: 25%
浏览 22

PHP Sweet Alert页面重定向

I Have Used The Sweet Alert For Delete using AJAX, And I set Page redirection after Deleteing. Whenever I Click delete, It asks Confirm or not buttons, If i click Yes-Confirm it will delete,and the Page Was Redirected. I Want like After deleteing success message "OK Successfully Deleted" That time only page Was Refreshed,

 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条回答 默认 最新

  • weixin_33701617 2017-12-16 10:59
    关注

    Remove this line On Success

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

    Write in some other action ex. On sweet alert close action

    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度