最新更新 sitemap 网站制作设计本站搜索
网页设计
国外网站 韩国网站 个人主页 手提袋设计 CSS 网页特效 平面设计 网站设计 Flash CMS技巧 服装网站 php教程 photoshop 画册 服务器选用 数据库 Office
虚拟主机 域名注册 云主机 网页设计 客服QQ:8208442
当前位置:首页 > 编程开发 > asp教程

ASP开发中一个AJAX局部刷新的例子

日期:03-29    来源:中国设计秀    作者:cnwebshow.com

终于睛天了.d3B中国设计秀

一个Ajax局部刷新的例子:d3B中国设计秀

前台页面:d3B中国设计秀

 d3B中国设计秀

<%@LANGUAGE="VBSCRipT" CODEPAGE="65001"%>d3B中国设计秀
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">d3B中国设计秀
<html xmlns="http://www.w3.org/1999/xhtml">d3B中国设计秀
<head>d3B中国设计秀
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />d3B中国设计秀
<title>AJAX局部刷新</title>d3B中国设计秀
<script type="text/javascript">d3B中国设计秀
<!--d3B中国设计秀

//建立xmlhttpRequest对象d3B中国设计秀
var xmlhttp;d3B中国设计秀
try{d3B中国设计秀
    xmlhttp= new ActiveXObject('Msxml2.XMLHTTP');d3B中国设计秀
}catch(e){d3B中国设计秀
    try{d3B中国设计秀
        xmlhttp= new ActiveXObject('Microsoft.XMLHTTP');d3B中国设计秀
    }catch(e){d3B中国设计秀
        try{d3B中国设计秀
            xmlhttp= new XMLHttPRequest();d3B中国设计秀
        }catch(e){}d3B中国设计秀
    }d3B中国设计秀
}d3B中国设计秀

function getPart(url){d3B中国设计秀
    xmlhttp.open("get",url,true);d3B中国设计秀
    xmlhttp.onreadystatechange = function(){d3B中国设计秀
        if(xmlhttp.readyState == 4)d3B中国设计秀
        {d3B中国设计秀
            if(xmlhttp.status == 200)d3B中国设计秀
            {d3B中国设计秀
                if(xmlhttp.responseText!=""){d3B中国设计秀
                    document.getElementById("partdiv").innerHTML = unescape(xmlhttp.responseText);        d3B中国设计秀
                }d3B中国设计秀
            }d3B中国设计秀
            else{d3B中国设计秀
                document.getElementById("partdiv").innerHTML = "数据载入出错";d3B中国设计秀
            }d3B中国设计秀
        }d3B中国设计秀
    }d3B中国设计秀
    xmlhttp.setRequestHeader("If-Modified-Since","0");d3B中国设计秀
    xmlhttp.send(null);d3B中国设计秀
}d3B中国设计秀
setInterval("getPart('getPart.asp')",1000)d3B中国设计秀
//-->d3B中国设计秀
</script>d3B中国设计秀
</head>d3B中国设计秀

<body>d3B中国设计秀
<div id="partdiv"></div><!--局部刷新数据的容器-->d3B中国设计秀
</body>d3B中国设计秀
</html>d3B中国设计秀

 d3B中国设计秀

后台页面:[getPart.asp]d3B中国设计秀

 d3B中国设计秀

<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>d3B中国设计秀
<!--#include file="conn.asp"-->d3B中国设计秀
<%d3B中国设计秀
    dim rsd3B中国设计秀
    dim sqld3B中国设计秀

    d3B中国设计秀
    Set rs = Server.CreateObject("ADODB.Recordset")d3B中国设计秀
    sql = "select * from king_test"d3B中国设计秀
    rs.open sql,conn,1,1d3B中国设计秀
    if not (rs.bof and rs.eof) thend3B中国设计秀
    Response.Write("<table>")d3B中国设计秀
    Response.Write(escape("<tr><td>ID</td><td>关键字</td></tr>"))d3B中国设计秀
    do while not rs.eofd3B中国设计秀
%>d3B中国设计秀
<tr><td><%Response.Write(rs("id"))%></td><td><%Response.Write(escape(rs("keyword")))%></td></tr>d3B中国设计秀
<%d3B中国设计秀
    rs.movenextd3B中国设计秀
    loopd3B中国设计秀
    Response.Write("</table>")d3B中国设计秀
    end ifd3B中国设计秀
    rs.closed3B中国设计秀
    set rs = nothingd3B中国设计秀
    conn.closed3B中国设计秀
    Set conn = nothingd3B中国设计秀
%>d3B中国设计秀

本文引用地址:/bc/article_46349.html
网站地图 | 关于我们 | 联系我们 | 网站建设 | 广告服务 | 版权声明 | 免责声明