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

例一:
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 | 查看次数: 23976
回复回复Christena[2017-08-02 02:48 PM | del]
I appreciate the details on your internet site.
With thanks!
回复回复Trudy[2017-08-02 05:27 AM | del]
I love the data on your websites. With thanks.
回复回复Alejandrina[2017-07-31 02:57 AM | del]
Incredibly user pleasant website. Astounding information available on couple of gos to.
回复回复Andreas[2017-07-30 05:42 PM | del]
How are you, neat internet site you possess there.
回复回复Buster[2017-07-30 05:27 PM | del]
Thanks a ton! It is an fantastic internet site.
回复回复Ramiro[2017-07-30 10:24 AM | del]
Thanks intended for furnishing these superb data.
回复回复Noe[2017-07-30 08:32 AM | del]
Amazing, such a advantageous web-site.
回复回复Stephen[2017-07-30 07:01 AM | del]
Your advice is quite fascinating.
回复回复Tiffany[2017-07-29 10:56 PM | del]
Incredible such a important websites.
回复回复Carlo[2017-07-29 10:10 PM | del]
You're a very beneficial web site; could not make it without ya!
发表评论
昵 称:
密 码: 游客发言不需要密码.
内 容:
验证码: 验证码
选 项:
虽然发表评论不用注册,但是为了保护您的发言权,建议您注册帐号.
字数限制 1000 字 | UBB代码 开启 | [img]标签 开启