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

例一:
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 | 查看次数: 25571
回复回复Maritza[2017-08-10 07:23 AM | del]
The info is extremely appealing.
回复回复Kathrin[2017-08-10 07:17 AM | del]
Amazing....this is a invaluable internet site.
回复回复Dominga[2017-08-10 07:09 AM | del]
Passion the site-- extremely individual friendly and great deals to see!
回复回复Kourtney[2017-08-08 08:44 AM | del]
I value the knowledge on your websites. Thanks for your time!
回复回复Deb[2017-08-08 03:11 AM | del]
Il faudra tout simplement fournir une adresse e-mail valide et d'entrer un nom et le tour est joué !
IQ Possibility shouldn't be a rip-off.
回复回复Annis[2017-08-07 11:12 PM | del]
Maintain the excellent work !! Lovin' it!
回复回复Nell[2017-08-07 03:20 PM | del]
Astonishingly individual pleasant website. Astounding info readily available on couple of clicks on.
回复回复Phillip[2017-08-06 05:35 AM | del]
Hi there, good web-site you have got right now.
回复回复Rafael[2017-08-05 09:47 PM | del]
A Tempo Cirurgia Plástica resta em BH e também quer progredir a pundonor e a qualidade de vida dos seus pacientes.
回复回复Cornelius[2017-08-05 08:39 AM | del]
You're a very useful web site; couldn't make it without ya!
发表评论
昵 称:
密 码: 游客发言不需要密码.
内 容:
验证码: 验证码
选 项:
虽然发表评论不用注册,但是为了保护您的发言权,建议您注册帐号.
字数限制 1000 字 | UBB代码 开启 | [img]标签 开启