What would be the easiest way to update a HTML tag with the following php code?
<h1>
<?php
include "document.txt";
?>
</h1>
What I mean is like a timed update... every 10 second or every 2 seconds.
Take a look at AJAX. jQuery has a really easy to use function to make AJAX requests, see jQuery.ajax().
This example (modified from the jQuery page) is what you want:
function loadData() {
$.ajax({
url: "document.txt",
cache: false
}).done(function( html ) {
$("#results").html(html);
});
}
It'll get the contents of the document.txt file and add it to an element with the attribute id="results" like the following:
<h1 id="results"></h1>
You can then use window.setInterval to execute the code at a set interval.
window.setInterval(loadData, 10000);
$("h1").load(".../update.php");