weixin_33699914 2016-10-12 04:22 采纳率: 0%
浏览 49

PHP:强制重定向页面

I have page which is calling through JQuery ajax. I do update in page experience.php. Hence, update part is working fine.

<?php
if( isset($_POST["update"]) ) {

        $status = false;
        $status = $experience->update($_POST);

        if($status) {
                $idh = md5($_SESSION["mainid"].$_SESSION["tsa_gong"]);
                header("Location: particular_one.php?idh=$idh&ajax_show=experience");
       } else {
             echo '<p style="color: #fff;">Error: cannot update</p>';
       }
}

But PHP header function is not working fine. It has following error. And it hangs in there which looks ugly for user.

[WARNING] Warning: Cannot modify header information - headers already sent by..

I want to ignore warning or error I get. I want PHP to forcefully redirect to page I intended. Is there any ways to achieve that?

  • 写回答

1条回答 默认 最新

  • weixin_33698043 2016-10-12 04:35
    关注

    you can use inline JavaScript

    header("Location: particular_one.php?idh=$idh&ajax_show=experience");

    echo "<script type='text/javascript'>window.location.href = 'particular_one.php?idh={$idh}&ajax_show=experience';</script>";
    
    评论

报告相同问题?

悬赏问题

  • ¥15 Python时间序列如何拟合疏系数模型
  • ¥15 求学软件的前人们指明方向🥺
  • ¥50 如何增强飞上天的树莓派的热点信号强度,以使得笔记本可以在地面实现远程桌面连接
  • ¥20 双层网络上信息-疾病传播
  • ¥50 paddlepaddle pinn
  • ¥20 idea运行测试代码报错问题
  • ¥15 网络监控:网络故障告警通知
  • ¥15 django项目运行报编码错误
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services