【问题标题】:How to show sweeat alert before post the URL如何在发布 URL 之前显示甜蜜警报
【发布时间】:2020-02-06 05:18:07
【问题描述】:

我是第一次使用 sweeatalert。如何在发布 URL 之前显示确认出汗警报。 我想在发布 URL 之前显示 sweeatalert。谢谢

<!--  -->
<script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script>
<a href="<?=base_url();?>/method/post/<?= $data['id'] ?>" class="badge badge-danger float-right ml-1" onclick='return onButton();'>hapus</a>
<script>
    function onButton(){
       event.preventDefault();
       swal({
            title: "Are you sure?",
            text: "Once deleted, you will not be able to recover this imaginary file!",
            icon: "warning",
            buttons: true,
            dangerMode: true,
        })
        .then((willDelete) => {
            if (willDelete) {

                swal("Poof! Your imaginary file has been deleted!", {
                    icon: "success",                                  
                });
            } else {
                swal("Your imaginary file is safe!");
            }
        });
    };
</script>
<!--  -->

【问题讨论】:

    标签: php html regex sweetalert


    【解决方案1】:
    <link rel="stylesheet" type="text/css" href="http://192.168.2.40/Always_Fresh_Backend/backend/bower_components/sweetalert/css/sweetalert.css">
    
    <script type="text/javascript" src="http://192.168.2.40/Always_Fresh_Backend/backend/bower_components/sweetalert/js/sweetalert.min.js"></script>
    
    function sweetalert() {
     swal({
        title: "Are you sure?",
        text: "msg",
        type: "warning",
        showCancelButton: true,
        confirmButtonClass: "btn-danger",
        confirmButtonText: "Yes",
        closeOnConfirm: false
    },
    function(isConfirm){
        if (isConfirm) {
         $.ajax({
                url: "<?=BASEURL;?>/method/post/<?= $data['id'] ?>",
                type: "GET",
                beforeSend: function(){
                },
                complete: function(){
                },
                success: function (response) { 
    
                }
            });
        } else {
    
        }           
    

     function sweetalert() {
    		swal({
    			title: "Are you sure?",
    			text: "msg",
    			type: "warning",
    			showCancelButton: true,
    			confirmButtonClass: "btn-danger",
    			confirmButtonText: "Yes",
    			closeOnConfirm: false
    		},
    		function(isConfirm){
    			if (isConfirm) {
    			 $.ajax({
    					url: "link",
    					type: "GET",
    					beforeSend: function(){
    					},
    					complete: function(){
    					},
    					success: function (response) { 
    						
    					}
    				});
    			} else {
    				
    			}
    			
    		});
            
        }
    <link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-sweetalert/1.0.1/sweetalert.min.css" rel="stylesheet"/>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-sweetalert/1.0.1/sweetalert.min.js"></script>
    
    
    <a href="#" class="badge badge-danger float-right ml-1" onclick='return sweetalert();'>hapus</a>

    【讨论】:

    • 链接[=BASEURL;?>/method/post/= $data['id'] ?>],如何在javascript中输入。?
    • 我已经更新了代码,请检查。如果此答案对您有帮助,请接受此答案,以便对其他人有所帮助
    猜你喜欢
    • 2021-09-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-20
    • 1970-01-01
    • 1970-01-01
    • 2021-10-26
    • 2018-07-25
    相关资源
    最近更新 更多