douzhang5295 2019-01-14 20:04
浏览 31

php中的睡眠功能导致我的页面挂起

I've been looking for hours for a solution to this problem.

I have a panel which takes everything in a given directory and displays it. I would like it to do this every 10 seconds because right now you have to refresh your entire page.

So when I do this

GetLogs(); sleep(5); GetLogs();

Instead of getting the directories, displaying them, waiting 5 seconds, and then displaying them again, it simply does GetLogs();, waits for 5 seconds then does it again, and then load my page. I have seen people use AJAX but it's a bit out of my league for this problem I think. I've read that changing my apache settings or php settings would resolve this problem but I have no idea how. I also looked into session_write_close and session_start but these do nothing, These functions are being called from within this php file. please help me!

I was stupid and for some reason thought I could use a server side language to sleep client-side, my bad. Could someone spoonfeed me an ajax call please?

  • 写回答

2条回答 默认 最新

  • dselp3944 2019-01-14 21:04
    关注

    If you just want to refresh the page every 5 seconds you could use

    <?php
    header("Refresh: 5");
    ?>
    

    This must be sent before any other output

    评论

报告相同问题?