Jump to content

How to Display Contents of a Txt file, Live.


LAEinc. Creations

Recommended Posts

alright, I am trying to work on something for my site, but I am very in-experianced with ajax.

I bet what I am trying to do is simple, but I haven't had any luck with it this far :(

 

I need a php/ajax file, that can constantly check a "update.txt" file,

and as the .txt file changes on the server, it would automatically display the new contents of the text file on the webpage, without a required refresh.

Id like to have it as real-time as possible, but without overloading any servers.

 

Its not a chat box im wanting, its more of a real-time pagelog is what im looking for.

All I really need is to be able to display the contents of a .txt file, as the .txt file changes in real time.

 

Any Help Guys? Thank you sooo much in advanced ^^

 

a million ajax tuts out there.  Just c/p the ajax code onto your page, make the call to the php script. php script would be something like this:

 

<?php
echo file_get_contents('textfile.txt');
?>

 

use javascript's settimeout()  to call the ajax function every x seconds.

a million ajax tuts out there.  Just c/p the ajax code onto your page, make the call to the php script. php script would be something like this:

 

<?php
echo file_get_contents('textfile.txt');
?>

 

use javascript's settimeout()  to call the ajax function every x seconds.

 

I know 0 javascript and ajax, I am decent in PHP as of now though. Thank you for your fast reply, too :)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.