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

例一:
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:
相关日志:

评论: 373 | 引用: 0 | 查看次数: 23978
回复回复Cody[2017-07-24 03:10 PM | del]
Thanks for the purpose of offering these sort of wonderful data.
回复回复Susanne[2017-07-24 01:43 PM | del]
I enjoy this site - its so usefull and helpfull.
回复回复Jerrold[2017-07-24 08:35 AM | del]
Thank you so much for sharing your awesome web site.
回复回复Sabrina[2017-07-24 07:46 AM | del]
I enjoy this website - its so usefull and helpfull.
回复回复Chance[2017-07-24 07:34 AM | del]
Truly such a beneficial internet site.
回复回复Anton[2017-07-23 06:55 PM | del]
I value the data on your web sites. Regards!
回复回复Luciana[2017-07-22 11:32 PM | del]
You're a really beneficial site; could not make it without ya!
回复回复Renate[2017-07-22 12:35 AM | del]
Merely desired to point out I'm just happy that i came on the website page.
回复回复Ashly[2017-07-22 09:11 AM | del]
You have got the most impressive web sites.
回复回复Tanya[2017-07-22 07:40 AM | del]
Sustain the awesome job !! Lovin' it!
发表评论
昵 称:
密 码: 游客发言不需要密码.
内 容:
验证码: 验证码
选 项:
虽然发表评论不用注册,但是为了保护您的发言权,建议您注册帐号.
字数限制 1000 字 | UBB代码 开启 | [img]标签 开启