日期:2014-05-17 浏览次数:20553 次
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> </head> <body> <div id="test"></div> <script type="text/javascript"> function test(){ var aj; try{aj=new ActiveXObject("Msxml2.XMLHTTP");} catch(e){ try{aj=new ActiveXObject("Microsoft.XMLHTTP");} catch(E){aj=false;} } var time = Math.round(new Date().getTime() / 1000); if(!aj&&typeof XMLHttpRequest!=undefined)aj=new XMLHttpRequest(); aj.open("GET","b.php?time="+time,true); aj.setRequestHeader('Content-Type','application/x-www-form-urlencoded;charset=utf-8'); aj.onreadystatechange=function(){ if(aj.readyState==4&&aj.status==200){ document.getElementById("test").innerHTML += aj.responseText; test(); // 收到结果后重新建立连接 } } aj.send(null); } test(); </script> </body> </html>