php refresh page code example
Example 1: php refresh
header("Refresh:0");
header("Refresh:5");
header("Refresh:0; url=page2.php");
Example 2: php header refresh
header("Refresh:0");
header("Refresh:2");
header("Refresh:0; url=page2.php");
Example 3: php refresh page
header("Refresh:0");
Example 4: header refresh page php
header("Refresh:0");
header("Refresh:0; url=page2.php");
Example 5: 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);
}
}
});