asp+ajax,数据库中增加一条信息,自动弹出层

爵罗先生 2011-10-11 01:56:34
请问ajax读取到的新数据如何自动弹出层提醒?目前已经正常显示如:【您有N条未读消息】

接收页代码:

<%
Response.Buffer=True
Response.ExpiresAbsolute=Now()-1
Response.Expires=0
Response.CacheControl="no-cache"
Response.AddHeader "Pragma", "No-Cache"
%>
<!--#include file="conn.asp"-->
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>个人中心</title>
<link href="images/img2.css" rel="stylesheet" type="text/css" />
<script>
function GetData()
{
url="xml.asp";
var http = new ActiveXObject("Microsoft.XMLHTTP");
http.open("GET",url,false);
http.send();
var str = http.responseText;
bb.innerHTML=str;
setTimeout("GetData()",1000);
}
</script>
</head>
<body onLoad="javascript:GetData();">
<div class="avatar"><span onclick="location.href='user.asp'" id="id2" style="cursor:pointer;">短消息<font color="#FF0000"><span id="bb">...</span></font></span></div>
</div>
<div id="fa">
<div style="float:left; margin-left:10px; color:#0075A9; line-height:25px;"><strong>发送短消息</strong></div>
<iframe name="fa2" width="500" height="450" scrolling="no" frameborder="0" id="fa2"></iframe>
</div>
<div id="ok">
<div class="div" style="float:right;">
<input type="submit" class="input" value="发短消息" onclick="document.getElementById('fa').style.display='block';fa2.location.href='message.asp';"/>
</div>
</div>
</body>
</html>


ajax读取页面代码(xml.asp):

<%
Response.Buffer=True
Response.ExpiresAbsolute=Now()-1
Response.Expires=0
Response.CacheControl="no-cache"
Response.AddHeader "Pragma", "No-Cache"
%>
<!--#include file="conn.asp"-->
<%
sql="select * from Chat_ID where ID2s="&session("ID")&" and Chat_ID=0"
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,1,3
if rs.RecordCount=0 then
response.write""
else
%>
【您有<%=rs.RecordCount%>条未读消息】
<%end if%>
...全文
80 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
爵罗先生 2011-10-11
  • 打赏
  • 举报
回复
能不能具体点怎么改哦?
不动ajax和js哦
叫我梁大侠 2011-10-11
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 chinmo 的回复:]
var str = http.responseText;
bb.innerHTML=str;
在这里读做判断啊
判断是否为空,为空就不弹出提示,不为空再弹出提示
[/Quote]

++1
  • 打赏
  • 举报
回复
var str = http.responseText;
bb.innerHTML=str;
在这里读做判断啊
判断是否为空,为空就不弹出提示,不为空再弹出提示

28,390

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧