我在单击甜蜜警报中的按钮后尝试调用php
文件。此功能是登录帐户的确认。示例过程是注销活动帐户时,会弹出一条弹出消息,提示您是甜蜜的警报,如果您单击“确定”按钮,则它应该已经破坏了用户会话。有人可以帮我弄这个吗?
这是我的代码:
<a href="javascript:swal({title:'Logout',
text:'Do you want to logout this Account?'
, icon:'warning',
buttons: true,
dangerMode: true}).then((willOUT) => {
if (willOUT) {
url: 'page_logout.php', {
icon: 'success',
});
}
});"
class="nav-item dropdown-item">
Log out
</a>
答案 0 :(得分:1)
这将为您提供帮助。它可以带您到page_logout.php 在用
编写的swal代码中也存在一些错误<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<a href="#" id="a_id">Logout</p>
<script type="text/javascript" src="js/jquery-3.3.1.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/sweetalert/2.1.2/sweetalert.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#a_id").click(function(){
swal({title:'Logout',
text:'Do you want to logout this Account?',
icon:'warning',
buttons: true,
dangerMode: true
})
.then((willOUT) => {
if (willOUT) {
window.location.href = 'page_logout.php', {
icon: 'success',
}
}
});
});
});
</script>
</body>
</html>
或者如果您想在具有注销按钮的同一页面中显示消息,那么请在您的问题中使用URL代替page_logout.php的ajax请求。希望对您有帮助。
答案 1 :(得分:0)
尝试js:
stringToSign
答案 2 :(得分:0)
您可以将注销事件与功能
结合使用<script src="https://unpkg.com/sweetalert2@7.8.2/dist/sweetalert2.all.js"></script>
<a onClick="logout()">Logout</a>
<script>
function logout(){
swal({
title: 'Logout',
text: 'Do you want to logout this Account?',
type: 'warning',
showCancelButton: true,
confirmButtonColor: '#DD6B55',
confirmButtonText: 'Yes!',
cancelButtonText: 'No.'
}).then(() => {
if (result.value) {
// Call ajax page_logout.php File
} else {
// Close alert
}
});
}
OR
functio logout() {
swal({
title: 'Are you sure?',
text: "You won't be able to revert this!",
type: 'warning',
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonText: 'Yes, delete it!'
}).then(function() {
swal(
'Deleted!',
'Your file has been deleted.',
'success'
)
})
}
</script>