天天看點

xmlhttp定時無重新整理更新資料庫資料

用戶端:

<script language="javascript">

<!--

function callXMLHttp()

{

    try {

        xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");

    } catch(e) {

        xmlHttp = new XMLHttpRequest();

    }     xmlHttp.onreadystatechange = function() {

        if (xmlHttp.readyState == 4) {

            if (xmlHttp.status == 200) {

                var data = xmlHttp.responseText;

            }

        }

    }     xmlHttp.open("POST","XMLHttpServer.aspx);

    xmlHttp.send(null);

} window.setInterval("callXMLHttp()",5000);

-->

</script> 伺服器端(XMLHttpServer):

private void Page_Load(object sender, System.EventArgs e)

{

    //向資料庫中插入伺服器的目前時間

}