function LogoutClick() { var r=confirm("确定退出吗?"); if (r==true) { $.ajax({ type: "GET", url: baseURL + "/api/logout", data: {}, success: function(data){ if (data.code ==0 ){ alert("退出成功!"); location.href = "index.html"; } } }); } else { // alert("You pressed Cancel!"); } }
本文介绍了一个使用JavaScript实现的退出确认功能,通过弹窗询问用户是否确定退出,并利用AJAX发送GET请求到/api/logout接口完成退出操作。如果服务器响应成功,将跳转至index.html页面。
1万+

被折叠的 条评论
为什么被折叠?



