以下代码定时局部刷新,时间长会导致页面卡死?求解
<asp:ScriptManager ID="ScriptManager" runat="server">
</asp:ScriptManager>
<asp:Timer ID="FiveSeconds" Interval="5000" runat="server" />
<asp:UpdatePanel ID="UpdatePanel" runat="server">
<ContentTemplate>
<asp:Literal ID="CurrentTime" runat="server"></asp:Literal>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="FiveSeconds" EventName="Tick" />
</Triggers>
</asp:UpdatePanel>
<asp:ScriptManager ID="ScriptManager" runat="server">
</asp:ScriptManager>
<asp:Timer ID="FiveSeconds" Interval="5000" runat="server" />
<asp:UpdatePanel ID="UpdatePanel" runat="server">
<ContentTemplate>
<asp:Literal ID="CurrentTime" runat="server"></asp:Literal>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="FiveSeconds" EventName="Tick" />
</Triggers>
</asp:UpdatePanel>
setInterval("ff()",5000)
function ff(){
//这里使用ajax获取数据
}
</script>
有一点不一样 多了一个OnTick="Timer_Tick"
Ajax长连接模式,它的刷新是根据数据来执行的,如果有新数据返回,接收并解析显示 数据,然后发起新的Ajax请求,如果一段时间内,用户没有操作,则连接处于睡眠状态,一直等待有用户输入或者请求超时,然后发起下个Ajax请求。这样 做的好处是,每个消息都会即时推送到客户端,延迟极少;另外每次请求都是有意义的,与短连接对比,效率要高很多。但对于一个用户量很多,并且操作非常频繁 的网站,长连接模式也会出现过于频繁的刷新问题。目前IE对于HTTP连接数是有限制的,每个网页只能同时进行两个长连接,第三个长连接会被阻塞。长连接
http://blog.csdn.net/tongdoudpj/archive/2009/05/12/4174272.aspx
http://blog.csdn.net/heiyeshuwu/archive/2011/05/27/6450465.aspx