天天看点

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)

{

    //向数据库中插入服务器的当前时间

}