Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7008701
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:46:07+00:00 2026-05-27T21:46:07+00:00

I am writing a tail function in PHP, and using jQuery to refresh a

  • 0

I am writing a tail function in PHP, and using jQuery to refresh a div area with any content from a log. I am using a session in PHP to hold a file pointer so when the function in PHP is called again, from the setInterval (jQuery), it will know where it left off and print anything that is new to the end of the file. For some reason since I began to use a session i cant see it stream to browser until the task is finished. Please help me with this. Thanks!

Here is my jQuery:

setInterval(function() {
    $.get("ajax.php?function=tail", function(data) {
        $("#tail").append(data);
    }, 'html');
}, 2000);

Here is my PHP:

function tail() {
    $file = "/path/to/the/log/file.log";
    $handle = fopen($file, "r");

    if(isset($_SESSION['ftell'])) {   
        clearstatcache();
        fseek($handle, $_SESSION['ftell']); 

        while ($buffer = fgets($handle)) { 
            echo $buffer . "<br />";
        }   

        fclose($handle);
        $_SESSION['ftell'] = ftell($handle);        
    } else {
        fseek($handle, -1024, SEEK_END);
        $_SESSION['ftell'] = ftell($handle);
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T21:46:08+00:00Added an answer on May 27, 2026 at 9:46 pm

    try to flash the buffer after the echo with http://php.net/manual/en/function.ob-flush.php

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing a log tail -f application using jQuery on the client side.
I am writing a shell script to do a tail on a growing log
As I was writing this function I knew that I wouldn't get tail call
I am using 'tail -f' to follow a log file as it's updated; next
Writing something like this using the loki library , typedef Functor<void> BitButtonPushHandler; throws a
Writing a python program, and I came up with this error while using the
Writing an asynchronous Ping using Raw Sockets in F#, to enable parallel requests using
I'm writing a calculator with an ability to accept new function definitions. Being aware
I recently answered a question with an attempt at writing a quicksort function in
I'd like to see the .tail IL instruction, but the simple recursive functions using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.