<!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=gb2312" />
<title>www.dwww.cn 设计家园</title>
<script type="text/javascript">
function createxmlhttp()
{
xmlhttpobj = false;
try{
xmlhttpobj = new ActiveXObject;
}catch(e){
try{
xmlhttpobj=new ActiveXObject("MSXML2.XMLHTTP");
}catch(e2){
try{
xmlhttpobj=new ActiveXObject("Microsoft.XMLHTTP");
}catch(e3){
xmlhttpobj = false;
}
}
}
return xmlhttpobj;
}
function getAjax()
{
var xmlhttpobj = createxmlhttp();
if(xmlhttpobj){//如果创建对象xmlhttpobj成功
xmlhttpobj.open('get',"now.asp",true);//get方法
xmlhttpobj.send(null);
xmlhttpobj.onreadystatechange=function(){//客户端监控函数
if(xmlhttpobj.readystate==4){//服务器处理请求完成
if(xmlhttpobj.status==200){
var htmlxxx = xmlhttpobj.responseText;//获得返回值
document.getElementById("loadAjaxTips").innerHTML=htmlxxx;
}else{
document.getElementById("loadAjaxTips").innerHTML="<font color='red'>加载错误</font>";
}
}else{
document.getElementById("loadAjaxTips").innerHTML="";//服务器处理中
}
}
}
}
</script>
</head>
<body onLoad="getAjax('sms')">
<script>
window.setInterval("getAjax()",3000);//设定3秒调用一次
</script>
<span id="loadAjaxTips"></span>
</body>
</html>
now.asp
<%
Response.ContentType="text/html; charset=gb2312" '编码
Response.Buffer = True '防止缓存
Response.Expires = -1
Response.ExpiresAbsolute = Now() - 1
Response.Expires = 0
Response.CacheControl = "no-cache"
response.write Now()
response.end()
%>