View file dsgame_1303/ajax_clock.js

File size: 793B
function showClock() {
var obj = document.getElementById('clock');
var req;

if (window.XMLHttpRequest)	req = new XMLHttpRequest();
else if(window.ActiveXObject) {
    try {
        req = new ActiveXObject('Msxml2.XMLHTTP');  
    } catch (e){}									
    try {											
        req = new ActiveXObject('Microsoft.XMLHTTP');
    } catch (e){}
}

if (req) {
    req.onreadystatechange = function() {
    	if (req.readyState == 4 && req.status == 200)  
		{ obj.innerHTML = 'Московское время '+req.responseText; }        
    };  
    req.open("POST", 'xmlhttp.php', true);
    req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    req.send('clock=1&ajax=1');
} 
else alert("Браузер не поддерживает AJAX");
}

setInterval(showClock, 3000);