我前几天写了个程序,是每隔2秒刷新一下数据库,我平时喜欢用的浏览器是firefox和opera,在这两个浏览器上是可以及时从数据库中获取数据的,后来改成ie却发现不能及时的获取数据!为什么!我很郁闷是IE缓存吗!那也不对,还是aspx和IE之间有什么“默契”!请高手帮忙,以下是部分代码
刷新页面的代码,2秒
//定时刷新,初步定为2秒钟
function setTimers()
{
timeID = window.setTimeout( "updateAll()", refreshRate );//2秒执行一次
}
function updateAll()
{
window.clearTimeout(timeID);
getBufferText();
setTimers();
}
//获取这两个会员的聊天信息 ,显示前10条
function getBufferText()
{
userid = location.search.substring( 1, location.search.length );
url='../UChat/Server.aspx?action=GetMsg&' + userid;
req=getAjax();
req.onreadystatechange=function()
{
if( req.readyState==4)//&& req.Status==200
{
obj=getElement("chatbuffer");
alert(req.responseText);
obj.innerHTML = req.responseText;
scrollChatPane();
}
}
req.open('GET',url,true);
req.send(null);
} 2。ajax
function getAjax()
{
var XmlHttp;
try
{
XmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
}
catch(e)
{
try
{
XmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
catch(oc)
{
XmlHttp = null;
}
}
if(!XmlHttp && typeof XMLHttpRequest != "undefined")
{
XmlHttp = new XMLHttpRequest();
}
return XmlHttp;
}3.
//../UChat/Server.aspx?action=GetMsg&' + userid
//调用数据库部分代码为:
protected void processGetMsg()
{
//Response.Buffer = false;
int user = int.Parse(Request.QueryString["u"].ToString());
Response.Write(chat1.BufferText(this.UserID,user));
//Response.End(); }4。//chat1.BufferText()
//从数据库中获取数据谢谢
刷新页面的代码,2秒
//定时刷新,初步定为2秒钟
function setTimers()
{
timeID = window.setTimeout( "updateAll()", refreshRate );//2秒执行一次
}
function updateAll()
{
window.clearTimeout(timeID);
getBufferText();
setTimers();
}
//获取这两个会员的聊天信息 ,显示前10条
function getBufferText()
{
userid = location.search.substring( 1, location.search.length );
url='../UChat/Server.aspx?action=GetMsg&' + userid;
req=getAjax();
req.onreadystatechange=function()
{
if( req.readyState==4)//&& req.Status==200
{
obj=getElement("chatbuffer");
alert(req.responseText);
obj.innerHTML = req.responseText;
scrollChatPane();
}
}
req.open('GET',url,true);
req.send(null);
} 2。ajax
function getAjax()
{
var XmlHttp;
try
{
XmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
}
catch(e)
{
try
{
XmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
catch(oc)
{
XmlHttp = null;
}
}
if(!XmlHttp && typeof XMLHttpRequest != "undefined")
{
XmlHttp = new XMLHttpRequest();
}
return XmlHttp;
}3.
//../UChat/Server.aspx?action=GetMsg&' + userid
//调用数据库部分代码为:
protected void processGetMsg()
{
//Response.Buffer = false;
int user = int.Parse(Request.QueryString["u"].ToString());
Response.Write(chat1.BufferText(this.UserID,user));
//Response.End(); }4。//chat1.BufferText()
//从数据库中获取数据谢谢
建议地址栏后面加个随机数就像CSDN一样
非常感谢你的提醒,我加了一个随机函数立马见效!
谢谢!