javascript - PHP filesize won't update; even with clearstatcache();

672

I have this file:

<html>
</html>
<script>

    setInterval(function () {
            <?php clearstatcache(); ?>
            var ss = "<?php echo filesize('log.html'); ?>";
            console.log(ss);
    },100);

</script>

But if I empty out the filelog.html the browser still outputs the old filesize. Am I doing something wrong here? If so how can I fix it?

590

Answer

Solution:

Javascript you are running keeps outputting the same data that has been sent when the page loaded. Thus it never change, as it is not reading from server.

You would need to use ajax to re-read data from server whenever needed to update.

People are also looking for solutions to the problem: php - Records listed per page in Yii

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.