Javascript 使用php和jquery mobile的导航问题
我正在使用php和jquery mobile(最新版本),在导航方面遇到了一些问题 我有一个名为index.php的页面:Javascript 使用php和jquery mobile的导航问题,javascript,php,jquery,jquery-mobile,Javascript,Php,Jquery,Jquery Mobile,我正在使用php和jquery mobile(最新版本),在导航方面遇到了一些问题 我有一个名为index.php的页面: <a href="logout.php">Sign Out</a> 单击链接时,它会重定向到logout.php。logout.php页面如下所示: <?php session_start(); unset($_SESSION['username']); if(session_destroy()) {
<a href="logout.php">Sign Out</a>
单击链接时,它会重定向到logout.php。logout.php页面如下所示:
<?php
session_start();
unset($_SESSION['username']);
if(session_destroy()) {
header("Location: login.php");
}
?>
发生的情况是浏览器中的URL更改为logout.php并显示一个空白页面。它不会转到login.php页面。如果我使用浏览器上的刷新按钮刷新页面,它将重定向到login.php
通过谷歌搜索问题,我发现这可能是php头调用的问题,因此我尝试使用javascript,但没有成功:
<?php
session_start();
unset($_SESSION['username']);
if(session_destroy()) {
//header("Location: index.php");
?>
<script>window.location.replace("index.php");</script>
<?php
}
?>
window.location.replace(“index.php”);
试试这个:
session_start();
unset($_SESSION['username']);
header("Location: login.php");
尝试通过以下方式将
data ajax=“false”
添加到注销链接:
<a href="logout.php" data-ajax="false">Sign Out</a>
我找到了原因。这是检查的条件!isset
。我已将isset更改为空,现在可以使用。谢谢您的回复。我已经尝试过了,同样的结果也出现了。我已经尝试过更新答案,同样的结果。也许这会对你有所帮助:谢谢你的回复。我以前在另一个问题中读到过这一点,但不幸的是,它不起作用。