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

例一:
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 | 查看次数: 23977
回复回复Vickie[2017-07-22 06:34 AM | del]
Just simply wanted to say I'm just pleased that i happened in your web site!
回复回复Gertrude[2017-07-21 09:10 PM | del]
Thanks pertaining to offering these sort of wonderful subject matter.
回复回复Sheldon[2017-07-21 04:45 PM | del]
Superb content you have in here.
回复回复Muhammad[2017-07-20 11:45 PM | del]
You're a very beneficial site; could not make it without ya!
回复回复Belen[2017-07-20 09:12 PM | del]
Maintain the great job and generating the group!
回复回复Erica[2017-07-20 03:22 PM | del]
The tips is very unique.
回复回复Garfield[2017-07-20 10:09 AM | del]
Whoa, this is a useful websites.
回复回复Shanon[2017-07-19 08:59 PM | del]
Sustain the great work and bringing in the group!
回复回复Christena[2017-07-19 08:15 PM | del]
Thanks for the purpose of supplying this type of well put together write-up.
回复回复Elliott[2017-07-19 05:24 PM | del]
With thanks for sharing your terrific webpage.
发表评论
昵 称:
密 码: 游客发言不需要密码.
内 容:
验证码: 验证码
选 项:
虽然发表评论不用注册,但是为了保护您的发言权,建议您注册帐号.
字数限制 1000 字 | UBB代码 开启 | [img]标签 开启