Live feed of an updating file

前端 未结 2 1835
清歌不尽
清歌不尽 2020-12-21 07:56

I have a php file that prints the last 50 lines of a txt file. However, this file gets appended every second and would like to view a \"live feed\" of the action. How can th

2条回答
  •  爱一瞬间的悲伤
    2020-12-21 08:35

    With ajax. If you need cross-browser compatibility, replace the AJAX function I provided with one from a library like jQuery.

    
    

    You will have to create a php file called myphpfile.php (or change the code above to reference the correct file) and put the following in it (as taken from your question):

    ', $output);         //add newlines
    ?>
    

提交回复
热议问题