ajax局部刷新
setInterval("refreshTime()",1000); //每格1秒刷新一次
funciton refreshTime()
{
var dateObj = new Date();
time.innerHTML = dateObj.toLocaleDateString(); //刷新div里面的内容
}
-------------------------------------------------------------------------------------------------
function doRef()
{
var url = "xxx.aspx"
var dateRequest = new ActiveXObject("Microsoft.XMLHTTP");
dateRequest.abort() ;
dateRequest.open( "GET", url , true );
dateRequest.onreadystatechange = onSendSelf ;
dateRequest.send() ;
function onSendSelf()
{
if( dateRequest.readyState != 4 )
{
return ;
}
var theDate = dateRequest.responseText
;//如果出现编码问题,可以在服务端escape一下,然后在这里使用unescape( responseText )
theDiv.innerHTML = theDate ;
}
}
setInterval( doRef , 1000 ) ;//1秒刷新一次,有点快
--------------------------------------------------------------------------------------------------
runat="server">
runat="server">
runat="server">
Interval="1000" OnTick="Timer1_Tick">
runat="server">
=====在后台Timer1_Tick事件加上
// Interval="1000" 是设置刷新的时间间隔
TextBox1.Text=DateTime.Now