XMLhttp学习应用
生活随笔
收集整理的這篇文章主要介紹了
XMLhttp学习应用
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
Client.htm頁面代碼如下: <!DOCTYPE?html?PUBLIC?"-//W3C//DTD?XHTML?1.0?Transitional//EN"?"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html?xmlns="http://www.w3.org/1999/xhtml"?>
<head>
????<title>客戶端</title>
????????<script?type="text/javascript">
????????var?XmlHttp?=?new?ActiveXObject("Microsoft.XMLhttp");
????????function?sendAJAX()
????????{
????????????XmlHttp.Open("POST","receive.aspx",true);
????????????XmlHttp.send(null);
????????????XmlHttp.onreadystatechange=ServerProcess;
????????}
????????function?ServerProcess()
????????{
????????????if?(XmlHttp.readystate==4?||?XmlHttp.readystate=='complete')
????????????{
????????????????document.getElementById('nameList').innerHTML?=XmlHttp.responsetext;
????????????}
????????}
????????setInterval('sendAJAX()',1000);
????????</script>
????</head>
????<body>
????????<div?id="nameList"></div>
????</body>
</html>
Receive.aspx CodeBehind代碼:
protected?void?Page_Load(object?sender,?EventArgs?e)
????{
????????PerformanceCounter?myMemory?=?new?PerformanceCounter();
????????myMemory.CategoryName?=?"Memory";
????????myMemory.CounterName?=?"Available?KBytes";
????????string?txtResult?=?"-->當前可用內存:"?+myMemory.NextValue().ToString()?+?"KB";
????????Response.Write(DateTime.Now.ToLongTimeString()?+?txtResult);
????}
<html?xmlns="http://www.w3.org/1999/xhtml"?>
<head>
????<title>客戶端</title>
????????<script?type="text/javascript">
????????var?XmlHttp?=?new?ActiveXObject("Microsoft.XMLhttp");
????????function?sendAJAX()
????????{
????????????XmlHttp.Open("POST","receive.aspx",true);
????????????XmlHttp.send(null);
????????????XmlHttp.onreadystatechange=ServerProcess;
????????}
????????function?ServerProcess()
????????{
????????????if?(XmlHttp.readystate==4?||?XmlHttp.readystate=='complete')
????????????{
????????????????document.getElementById('nameList').innerHTML?=XmlHttp.responsetext;
????????????}
????????}
????????setInterval('sendAJAX()',1000);
????????</script>
????</head>
????<body>
????????<div?id="nameList"></div>
????</body>
</html>
Receive.aspx CodeBehind代碼:
protected?void?Page_Load(object?sender,?EventArgs?e)
????{
????????PerformanceCounter?myMemory?=?new?PerformanceCounter();
????????myMemory.CategoryName?=?"Memory";
????????myMemory.CounterName?=?"Available?KBytes";
????????string?txtResult?=?"-->當前可用內存:"?+myMemory.NextValue().ToString()?+?"KB";
????????Response.Write(DateTime.Now.ToLongTimeString()?+?txtResult);
????}
轉載于:https://www.cnblogs.com/AlexSky/archive/2008/06/09/1216300.html
總結
以上是生活随笔為你收集整理的XMLhttp学习应用的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 让网站性能最佳的34条黄金守则
- 下一篇: asp.net 得到上一页地址