Ajax(一)显示可用内存空间

打开VS,新建空网站,添加新项命名为Receive.aspx<br>
在后台的内容为:
 protected void Page_Load(object sender, EventArgs e)
    {
        PerformanceCounter myMeroy = new PerformanceCounter();
        myMeroy.CategoryName = "Memory";
        myMeroy.CounterName = "Available KBytes";
        string txtRelust = "-->可用的内存:" + myMeroy.NextValue().ToString() + "KB";
        Response.Write(DateTime.Now.ToLongTimeString()+"   "+ txtRelust);
    }
添加一个htm文件,命名为client.htm
 <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('div1').innerHTML = XmlHttp.responsetext;
             }
 这样就会出现一个不断变化的内存空间

原文地址:https://www.cnblogs.com/xuxiaorong/p/2420324.html