随笔-8  评论-4  文章-4  trackbacks-1

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);

    }
posted on 2008-06-09 17:59 Alex’Sky 阅读(117) 评论(0) 编辑 收藏
昵称:Alex’Sky
园龄:5年4个月
粉丝:4
关注:1
<2008年6月>
25262728293031
1234567
891011121314
15161718192021
22232425262728
293012345

搜索

 
 

常用链接

随笔分类

随笔档案

文章分类

相册

A.Web Sites

我的好友

友情博客

最新评论

阅读排行榜

评论排行榜

推荐排行榜