一个AJAX局部刷新 asp
2011-05-25 15:07
134 查看
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>AJAX局部刷新</title>
<script type="text/javascript">
<!--
//建立XMLHttpRequest对象
var xmlhttp;
try{
xmlhttp= new ActiveXObject(’’Msxml2.XMLHTTP’’);
}catch(e){
try{
xmlhttp= new ActiveXObject(’’Microsoft.XMLHTTP’’);
}catch(e){
try{
xmlhttp= new XMLHttpRequest();
}catch(e){}
}
}
function getPart(url){
xmlhttp.open("get",url,true);
xmlhttp.onreadystatechange = function(){
if(xmlhttp.readyState == 4)
{
if(xmlhttp.status == 200)
{
if(xmlhttp.responseText!=""){
document.getElementById("partdiv").innerHTML = unescape(xmlhttp.responseText);
}
}
else{
document.getElementById("partdiv").innerHTML = "数据载入出错";
}
}
}
xmlhttp.setRequestHeader("If-Modified-Since","0");
xmlhttp.send(null);
}
setInterval("getPart(’’getPart.asp’’)",1000)
//-->
</script>
</head>
<body>
<div id="partdiv"></div><!--局部刷新数据的容器-->
</body>
</html>
后台页面:[getPart.asp]
<!--#include file="conn.asp"-->
<%
dim rs
dim sql
Set rs = Server.CreateObject("ADODB.Recordset")
sql = "select * from king_test"
rs.open sql,conn,1,1
if not (rs.bof and rs.eof) then
Response.Write("<table>")
Response.Write(escape("<tr><td>ID</td><td>关键字</td></tr>"))
do while not rs.eof
%>
<tr><td><%Response.Write(rs("id"))%></td><td><%Response.Write(escape(rs("keyword")))%></td></tr>
<%
rs.movenext
loop
Response.Write("</table>")
end if
rs.close
set rs = nothing
conn.close
Set conn = nothing
%>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>AJAX局部刷新</title>
<script type="text/javascript">
<!--
//建立XMLHttpRequest对象
var xmlhttp;
try{
xmlhttp= new ActiveXObject(’’Msxml2.XMLHTTP’’);
}catch(e){
try{
xmlhttp= new ActiveXObject(’’Microsoft.XMLHTTP’’);
}catch(e){
try{
xmlhttp= new XMLHttpRequest();
}catch(e){}
}
}
function getPart(url){
xmlhttp.open("get",url,true);
xmlhttp.onreadystatechange = function(){
if(xmlhttp.readyState == 4)
{
if(xmlhttp.status == 200)
{
if(xmlhttp.responseText!=""){
document.getElementById("partdiv").innerHTML = unescape(xmlhttp.responseText);
}
}
else{
document.getElementById("partdiv").innerHTML = "数据载入出错";
}
}
}
xmlhttp.setRequestHeader("If-Modified-Since","0");
xmlhttp.send(null);
}
setInterval("getPart(’’getPart.asp’’)",1000)
//-->
</script>
</head>
<body>
<div id="partdiv"></div><!--局部刷新数据的容器-->
</body>
</html>
后台页面:[getPart.asp]
<!--#include file="conn.asp"-->
<%
dim rs
dim sql
Set rs = Server.CreateObject("ADODB.Recordset")
sql = "select * from king_test"
rs.open sql,conn,1,1
if not (rs.bof and rs.eof) then
Response.Write("<table>")
Response.Write(escape("<tr><td>ID</td><td>关键字</td></tr>"))
do while not rs.eof
%>
<tr><td><%Response.Write(rs("id"))%></td><td><%Response.Write(escape(rs("keyword")))%></td></tr>
<%
rs.movenext
loop
Response.Write("</table>")
end if
rs.close
set rs = nothing
conn.close
Set conn = nothing
%>
相关文章推荐
- 运用 Ajax技术 实现一个局部刷新显示的小例子
- asp+ajax 无刷新新闻列表,点击分页不局部刷新(代码,有下载)
- ASP.NET 用 AjaxOptions 实现局部刷新
- ajax局部刷新一个div下的jsp
- 新写的一个使用ASP.NET AJAX中的UpdatePanel控件实现GridView的无刷新删除,更新,添加,查询!
- ASP.NET使用ajax实现分页局部刷新页面功能
- 使用php后台给自己做一个页面路由,配合ajax实现局部刷新。
- ASP.NET下Ajax局部刷新简单应用
- ASP.NET AJAX UpdatePanel 不能实现局部刷新原因
- Ajax请求返回一个页面,实现页面局部刷新
- ajax局部刷新一个div下的jsp
- 21.5 UpdatePanelAnimation局部刷新动画控件(征服ASP.NET 2.0 Ajax——Web开发技术详解)
- 一个AJAX局部刷新的例子
- VS2003项目转为VS2005后ASP.NET ajax不能局部刷新的问题
- asp.net 局部刷新以后怎么弹出一个对话框?
- 一个AJAX局部刷新的例子
- Asp.net_Ajax局部刷新初步认识
- ASP.Net网站开发ajax局部刷新问题
- 一个AJAX局部刷新的例子
- AJAX 怎样在一个UpDatePanel中刷新另一个updatePanel (asp.net C#)