Ajax的应用

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
    <title>Blank Page</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <script type="text/javascript">
        var url, x, empName, empNo, empCount, txt;
        var xmlHttp;
        function createXmlHttpRequest() {
            if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
                xmlHttp = new XMLHttpRequest();
            }
            else {// code for IE6, IE5
                xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
            }
        }

        //刷新
        function refeshData(url) {
            var url = url;
            createXmlHttpRequest();
            xmlHttp.onreadystatechange = DisplayData;
            xmlHttp.open("GET", url, true);
            xmlHttp.send();
            setTimeout("refeshData('" + url + "')", 80);
        }

        function DisplayData() {
            if (xmlHttp.readyState == 4) {
                if (xmlHttp.status == 200) {
                    if (x == null) {
                        x = xmlHttp.responseXML.documentElement.getElementsByTagName("SingleTable");
                        empCount = x.length - 1;  //防止下面取值數組溢出
                    }
                    if (empCount > 0) {
                        empName = x[empCount].getElementsByTagName("NAME");
                        empNo = x[empCount].getElementsByTagName("EMPLOYEE_NO");
                        txt = empName[0].firstChild.nodeValue + "  " + empNo[0].firstChild.nodeValue;
                        document.getElementById("count").innerHTML = txt;
                        empCount--;
                    }
                }
            }
        }

        function init(url) {
            window.setTimeout("refeshData('" + url + "')", 800);
        }
    </script>
</head>
<body scroll="no" bgcolor="#eeeeee" οnlοad="init('Ajax/db.xml');">
    <!-- οnlοad="init('Ajax/db.xml');"-->
    <table width="100%" height="700" background="images/lott.jpg">
        <tr>
            <td>
                <div id="count" style="text-align: center; text-decoration: underline; font-family: Arial, Helvetica, sans-serif;
                    font-size: 100px; font-weight: bolder">
                    MITAC 00000</div>
                <div style="text-align: center; font-family: Tahoma; font-size: 20pt; font-weight: bolder">
                    Loading......
                    <br />
                    <br />
                    <br/>
                    <input id="Button1" type="button" style="background-position: 0% 0%; height: 64px;
                        width: 208px; background-color: #FF0000; background-attachment: inherit; border-color: Red;
                        background-image: url('Images/end.gif'); background-repeat: repeat;"  οnclick="window.close();"  />
            </td>
            </div>
            <!--<button οnclick="refeshData('Ajax/db.xml')">
                    start</button>-->
        </tr>
    </table>
</body>
</html>


 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值