当数据库中的记录改变时,就刷新页面,显示改动后的数据---如何实现?

divineka 2003-04-08 01:46:23
rt:
就是说,在后台管理程序中,改变了数据库中的内容,这时,前台页面就自动刷新,该怎么做呢?
...全文
359 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
divineka 2003-04-15
  • 打赏
  • 举报
回复
啊哦~~~it's English.....那也得啃啊.....骨头....
divineka 2003-04-15
  • 打赏
  • 举报
回复
晕,给我的网址怎么上不去,是不是我家宽带的问题呢?急死.....

saucer(思归, MS .NET MVP)
一会儿我开个贴子,你再来领分...
如果是完整的例子,能不能发到我的信箱里呢?
divineka@263.net
saucer 2003-04-14
  • 打赏
  • 举报
回复
Refresh Portion Of Your Web Page Using XMLHTTP
http://www.codeproject.com/jscript/refreshpartweb.asp
divineka 2003-04-14
  • 打赏
  • 举报
回复
有没有完整一点的例子或代码呢?对xmlhttp不是很了解啊~
saucer 2003-04-08
  • 打赏
  • 举报
回复
if you output that way, there is no way to tell on the client side, at least you should do

<%......
span=rs("span")
xpan=rs("xpan")

response.write span & "," & xpan
%>

then on the client side, you could use

xmlhttp.send();
if (xmlhttp.status == 200)
{
var s = xmlhttp.responseText;
var a = s.split(",");
......
divineka 2003-04-08
  • 打赏
  • 举报
回复
还有就是在你的程序中:
for (var i=0; i < nodes.length; i++)
xmldoc.documentElement.appendChild(nodes[i].cloneNode(true));
为什么会无限的执行呢?
divineka 2003-04-08
  • 打赏
  • 举报
回复
40% :(

如果在getxml.asp中
<%......
span=rs("span")
xpan=rs("xpan")

response.write span
response.write xpan
'是否要这样写?
%>
那在xmlhttp.asp中,应该怎么写?
divineka 2003-04-08
  • 打赏
  • 举报
回复
消化ing
saucer 2003-04-08
  • 打赏
  • 举报
回复
here is some code you can play with

1. xmlhttp.asp:
<xml id="xmldoc">
<people>
<person>
<name>John</name>
<age>28</age>
</person>
<person>
<name>Jack</name>
<age>23</age>
</person>
</people>
</xml>

<table id="mytable" datasrc="#xmldoc" border="1" cellspacing="0" cellpadding="0">
<thead>
<th>Name</th><th>Age</th>
</thead>
<tr>
<td><span datafld="name"></span></td>
<td><span datafld="age"></span></td>
</tr>
</table>

<script language="javascript">
function window.onload()
{
setTimeout("getXmlData()",1000);
}

var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
function getXmlData()
{
xmlhttp.open("GET","getXml.asp",false);
xmlhttp.send();
if (xmlhttp.status == 200)
{
var newdoc = xmlhttp.responseXML;
var nodes = newdoc.documentElement.childNodes;

for (var i=0; i < nodes.length; i++)
xmldoc.documentElement.appendChild(nodes[i].cloneNode(true));

//mytable.refresh();

}
else
{
alert("something is wrong:" + xmlhttp.statusText);
}

setTimeout("getXmlData()",1000);
}
</script>

2. getxml.asp
<%
'get data from the database here
Response.ContentType="text/xml"
sXML = "<people><person><name>a</name><age>12</age></person><person><name>b</name><age>24</age></person></people>"
Response.Write(sXML)
%>
divineka 2003-04-08
  • 打赏
  • 举报
回复
我也知道用XMLHTTP可以实现这个功能,可是,具体怎么操作还不是很懂,看了很多例子,还是搞不明白,比如说,在数据接收页面中,所要显示的是"名字"和"年龄"两个字段的内容,那是不是要在数据提供页面中用两个字符串来存储从数据库中读出的这两个字段的内容,然后再发送到数据接收页面中,并在数据接收页面中用split把这两个字符串分解为两个数组,然后再循环显示?
saucer 2003-04-08
  • 打赏
  • 举报
回复
very difficult to do a PUSH, you have to refresh the page periodically to retrieve the new data or if you don't like refreshing, you can use remote scripting or XMLHTTP to retrieve any new data periodically and update the page using DHTML

28,390

社区成员

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

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