php - 虽然我使用 header('Location:test.php') 我必须重新加载页面
问题描述
$('#logOut').click(function()
{
<?php
//session_start(); comment this because this is called top of the page.
unset($_SESSION['email']);
unset($_SESSION['password']);
header('Location: test.php');
?>
});
这是里面的newnavbar.php
。test.php
页面加载此页面。
$(function(){
$("#nav-placeholder").load("newnavbar.php");
});
我也使用header('Refresh:0, url= test.php');
,但在这两种情况下,我都必须手动重新加载页面。
编辑 1
登录时发生相同的情况。登录后我必须重新加载页面,然后显示用户头像代替登录按钮。如果我重新加载两次,那么用户就退出了。
我也用
$('#signInSubmit').click(function()
{
$('#signIn').modal('toggle');
//alert("signup completed");
var email=document.getElementById('signInEmail').value;
var password = document.getElementById('signInPassword').value;
$.ajax({
url: 'signIn.php',
type: 'POST',
data: {
email: email,
password: password
},
success: function(data)
{
alert(data);
<?php header('Location: test.php'); ?>
},
error: function(data)
{
console.log(data);
}
});
});
但是,test.php
页面未显示成功。
解决方案
推荐阅读
- c - C - 循环不继续
- c - OpenMP C 程序运行速度比顺序代码慢
- java - 如何使用 log4j 在 Spring Boot 中创建最近 5 天的记录器 zip 文件?
- javascript - 在 php 中使用 javascript 变量作为标签
- java - 即使映射了 URL,Spring 也会返回 HTTP 404
- angular - 角度路由 - 使用附加参数导航到同一个组件而不破坏组件
- ios - ios 11.4 上的 SceneView hittest 崩溃,在 iOS 12+ 上运行
- php - MySQL / MariaDB 不接受 JSON 格式?无法创建数据库
- django - 使用多个数据库进行 Django 身份验证
- json - 从 localhost:8080/api/spec JSON 获取 IntelliJ 以根据 CoreAPI Spec 自动完成