无刷新显示即时更新数据两例

例一:
example1.htm
-------------------------------------
<html>
<head>
<title>无刷新</title>

<script language="JavaScript" type="text/javascript">
function GetData(url)
{
url="example1.asp";//调用页面
try
{
DataLoad.src = url;
}
catch(e)
{
return false;
}
{
var timeoutid = setTimeout("GetData()",1000)
}
}
</script>
<script id="DataLoad" language="JavaScript" type="text/javascript" defer></script>

<body onLoad="javascript:GetData();">
<span id=loadcontent>数据载入中……</span>
</body>
-------------------------------------
数据调用程序:example1.asp
--------------------------------------
loadcontent.innerHTML="<%=now()%>"

例二:
example2.htm
-------------------------------------
<HTML>
<head>
<title>无刷新</title>

<script language="javascript">
function GetData()
{
url="example2.asp";//调用页面

var http = new ActiveXObject("Microsoft.XMLHTTP");
http.open("GET",url,false);
http.send();
var str = http.responseText;
loadcontent.innerHTML=str;
setTimeout("GetData()",1000);
}
</script>

</head>
<BODY onload="javascript:GetData();">
<span id="loadcontent">数据载入中……</span>
</BODY>
</HTML>
-------------------------
数据调用程序:example2.asp
---------------------------
<%=now%>
---------------------------

文章来自: 网络
引用通告: 查看所有引用 | 我要引用此文章
Tags:
相关日志:

评论: 375 | 引用: 0 | 查看次数: 25567
回复回复Marilou[2017-07-29 09:37 PM | del]
You've got one of the better sites.
回复回复Ashli[2017-07-29 08:12 PM | del]
Great website! It looks extremely professional! Keep up the excellent work!
回复回复Belen[2017-07-29 03:58 PM | del]
I value the data on your website. Thanks!
回复回复Darlene[2017-07-29 06:53 AM | del]
You've got very good knowlwdge right here.
回复回复Corrine[2017-07-29 03:46 AM | del]
Astonishingly user friendly site. Tremendous info readily available on couple of clicks.
回复回复Rhys[2017-07-28 08:44 PM | del]
Awesome website you've here.
回复回复Lynda[2017-07-28 11:14 AM | del]
Very good website you possess here.
回复回复Caleb[2017-07-28 07:29 AM | del]
Many thanks really practical. Will certainly share website with my friends.
回复回复Margart[2017-07-28 07:26 AM | del]
Terrific Site, Keep up the useful job. Appreciate it!
回复回复Guy[2017-07-28 07:26 AM | del]
Many thanks, this website is really helpful.
发表评论
昵 称:
密 码: 游客发言不需要密码.
内 容:
验证码: 验证码
选 项:
虽然发表评论不用注册,但是为了保护您的发言权,建议您注册帐号.
字数限制 1000 字 | UBB代码 开启 | [img]标签 开启