PHP -Aktualisierung Seite
header("Refresh:0");
A-Décamètre
header("Refresh:0");
window.addEventListener('load', function()
{
var xhr = null;
getXmlHttpRequestObject = function()
{
if(!xhr)
{
// Create a new XMLHttpRequest object
xhr = new XMLHttpRequest();
}
return xhr;
};
updateLiveData = function()
{
var now = new Date();
// Date string is appended as a query with live data
// for not to use the cached version
var url = 'livefeed.txt?' + now.getTime();
xhr = getXmlHttpRequestObject();
xhr.onreadystatechange = evenHandler;
// asynchronous requests
xhr.open("GET", url, true);
// Send the request over the network
xhr.send(null);
};
updateLiveData();
function evenHandler()
{
// Check response is ready or not
if(xhr.readyState == 4 && xhr.status == 200)
{
dataDiv = document.getElementById('liveData');
// Set current data text
dataDiv.innerHTML = xhr.responseText;
// Update the live data every 1 sec
setTimeout(updateLiveData(), 1000);
}
}
});
function data() {
var ret = [];
ret.push({
y: 'Today',
a: <?php echo $data; ?>
});
return ret;
}
var graph = Morris.Bar({
element: 'graph',
data: data(),
xkey: 'y',
ykeys: ['a'],
labels: ['random label']
});
function update() {
graph.setData(data());
}
setInterval(update, 60000);