<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
<title>Пример</title>
<script language="JavaScript" type="text/javascript">
function GetNewVars(name,text,date)
{
document.getElementById('name').innerHTML = name;
document.getElementById('text').innerHTML = text;
document.getElementById('date').innerHTML = date;
};
function processReqChange()
{
if (req.readyState == 4)
{
if (req.status == 200)
{
response = req.responseXML.documentElement;
method = response.getElementsByTagName('method')[0].firstChild.data;
name = response.getElementsByTagName('name')[0].firstChild.data;
text = response.getElementsByTagName('text')[0].firstChild.data;
date = response.getElementsByTagName('date')[0].firstChild.data;
eval(method + ' (name,text,date)');
};
};
};
function loadXMLDoc(url)
{
if (window.XMLHttpRequest) {
req = new XMLHttpRequest();
req.onreadystatechange = processReqChange;
req.open("GET", url, true);
req.send(null);
} else if (window.ActiveXObject) {
req = new ActiveXObject("Microsoft.XMLHTTP");
if (req) {
req.onreadystatechange = processReqChange;
req.open("GET", url, true);
req.send();
};
};
};
function Timer()
{
Second--;
document.getElementById('time').innerHTML = Second;
if (Second == Update)
{Update = Second - 10;
id++;
url = 'http://localhost/js_test.php?id='+id;
loadXMLDoc(url);
};
};
Second = 60;
Update = Second - 10;
id = 1;
interval = setInterval(Timer,1000);
</script>
</head>
<body>
<div id='time'></div>
<div id='name'></div>
<div id='text'></div>
<div id='date'></div>
<script type="text/javascript">document.getElementById('time').innerHTML = Second;</script>
</body>
</html>