如果将clock.innerHTML=_time;移到注释 //①下面的话,那么_time将没有值,求教
<html><head>
<style type="text/css">
.clock
{
padding :10px;
color:white;
text-align:center;
height:12%;
width:25%;
margin-left:35%;
margin-right:35%;
border:solid 10px black;
background:gray;
}
</style>
<meta http-equiv="content-type" content="text/html; charset=GBK" />
<script type="text/javascript" >
function disp()
{
var xmlhttp;
var _time="sss";
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
_time=xmlhttp.responseText;
clock.innerHTML=_time;
}
}
xmlhttp.open("POST","MyJsp.jsp?t="+Math.random(),true);
xmlhttp.send();
//①
}
</script>
</head>
<body >
<div id="clock" class="clock" > </div>
<script type="text/javascript">
setInterval("disp()",1000);
</script>
</body>
</html>