doupang5433 2012-10-20 21:16
浏览 123

后台脚本完成后刷新页面

I am using ob_ to do some background processing

$buffer = ob_get_contents();
header("Connection: close");
ignore_user_abort(true);
ob_start();
echo $buffer;
$size=ob_get_length();
header("Content-Length: $size");
ob_end_flush();
flush();
ob_end_clean();
file_get_contents($uri.'?loadchanges=1');

the script works fine but I need to refresh the page after

  file_get_contents($uri.'?loadchanges=1');

i tried

header( "refresh:0;" );

after or before

echo $buffer;

but it is refreshing twice and I am sure I dont need it there , I need it after the background process is finished.

any help is apreciated

  • 写回答

1条回答 默认 最新

  • douchuo1963 2012-10-20 22:58
    关注

    Am not sure what you want to do but using Refresh:0 would result in continues loop you need to look for a way to make sure it does not refresh more than once also calling flush or ob_flush before calling header is not a good idea ;

    Try

    error_reporting(E_ALL);           //<-- Add to catch posible errors
    ini_set("display_errors", "on");  //<------------^
    
    
    if (!isset($_GET['refreshed'])) {
        header("Refresh: 0; URL=\"samplepage.php?refreshed=ok\"");
    }
    
    评论

报告相同问题?

悬赏问题

  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图