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

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

评论: 351 | 引用: 0 | 查看次数: 18872
回复回复Otilia[2017-09-02 10:18 PM | del]
I appreciate looking through your web sites.
Thanks a lot!
回复回复Valerie[2017-09-01 07:40 PM | del]
Keep up the good job and bringing in the group!
回复回复Mai[2017-08-30 07:58 AM | del]
Thanks a lot! It is definitely an incredible web site.
回复回复Aline[2017-08-29 02:06 PM | del]
Thanks for the purpose of delivering these types of well put together data.
回复回复Blake[2017-08-28 10:32 PM | del]
Great website! It looks really expert! Keep up the excellent job!
回复回复Ramona[2017-08-28 05:15 AM | del]
Much thanks! This a great site!
回复回复Buck[2017-08-28 04:00 AM | del]
I benefit from checking your websites. Cheers!
回复回复Rudy[2017-08-27 03:39 AM | del]
Good page, Keep up the great work. Regards!
回复回复Josefina[2017-08-26 10:29 AM | del]
Great looking site. Think you did a whole lot of your own coding.
回复回复Eleanor[2017-08-25 03:44 AM | del]
Regards for sharing your great web page.
发表评论
昵 称:
密 码: 游客发言不需要密码.
内 容:
验证码: 验证码
选 项:
虽然发表评论不用注册,但是为了保护您的发言权,建议您注册帐号.
字数限制 1000 字 | UBB代码 开启 | [img]标签 开启