php button to refresh page code example
Example: php refresh page without reloading
window.addEventListener('load', function()
{
var xhr = null;
getXmlHttpRequestObject = function()
{
if(!xhr)
{
xhr = new XMLHttpRequest();
}
return xhr;
};
updateLiveData = function()
{
var now = new Date();
var url = 'livefeed.txt?' + now.getTime();
xhr = getXmlHttpRequestObject();
xhr.onreadystatechange = evenHandler;
xhr.open("GET", url, true);
xhr.send(null);
};
updateLiveData();
function evenHandler()
{
if(xhr.readyState == 4 && xhr.status == 200)
{
dataDiv = document.getElementById('liveData');
dataDiv.innerHTML = xhr.responseText;
setTimeout(updateLiveData(), 1000);
}
}
});