how to reload php without refresh the php code example
Example 1: php refresh
header("Refresh:0");
header("Refresh:5");
header("Refresh:0; url=page2.php");
Example 2: 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);
}
}
});