客户端:
<script language="javascript">
<!--
function callXMLHttp()
{
try {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch(e) {
xmlHttp = new XMLHttpRequest();
}
<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;
}
}
}
if (xmlHttp.readyState == 4) {
if (xmlHttp.status == 200) {
var data = xmlHttp.responseText;
}
}
}
xmlHttp.open("POST","XMLHttpServer.aspx);
xmlHttp.send(null);
}
xmlHttp.send(null);
}
window.setInterval("callXMLHttp()",5000);
-->
</script>
-->
</script>
服务器端(XMLHttpServer):
private void Page_Load(object sender, System.EventArgs e)
{
//向数据库中插入服务器的当前时间
}
private void Page_Load(object sender, System.EventArgs e)
{
//向数据库中插入服务器的当前时间
}
博客展示了客户端使用JavaScript的XMLHttpRequest对象与服务器通信的代码,通过定时调用函数向服务器发送POST请求。服务器端代码则在页面加载时向数据库插入当前时间,体现了客户端、服务器与数据库之间的交互。
5323

被折叠的 条评论
为什么被折叠?



