我正在使用一些 JQuery 和 Ajax 以提交一些链接,其中一个正在工作,但其他两个没有。有人可以帮我吗?
阿贾克斯/jQuery:
//Logout button
$('#logout').click(function(e){
console.log('logout');
e.preventDefault();
$.post('logout.php', { data: '' }, function(data){
window.location.href = "./index.php";
} );
});
//Profile button
$('#profile_but').click(function(e){
console.log('profile');
e.preventDefault();
$.post('void.php', { data: '' }, function(data){
window.location.href = "./forum/ucp.php?i=173";
} );
});
//Account button
$('#account_but').click(function(e){
console.log('account');
e.preventDefault();
$.post('void.php', { data: '' }, function(data){
window.location.href = "./forum/ucp.php?i=profile&mode=reg_details";
} );
});
HTML:
<ul class="nav sub-menu"id='userSUBNAV' style='padding-left:10px;'>
<li><a id='profile_but' href='#'><span>My Profile</span></a></li>
<li><a id='account_but' href='#'><span>My Account</span></a></li>
<li><a id='logout' href='#'><span>Logout</span></a></li>
</ul>
唯一有效的是注销按钮。其他的甚至不会输出到控制台:3。有人可以解释为什么吗?...以及如何解决它?
还,
注销.php:
<?php
include 'user_functions.php';
if(!isLoggedIn()){
header("Location: index.php");
exit;
}
$user->session_kill();
echo "Logged out";
?>
和 void.php
<?php echo "void"; ?>