现在的位置: 首页 > 综合 > 正文

Ajax的一些小菜

2013年10月04日 ⁄ 综合 ⁄ 共 1205字 ⁄ 字号 评论关闭

 页面刷新
<!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>

显示内存空间
    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);
    }

DOM
<html>
<head>
<script type="text/javascript">
function ChangeColor()
{
document.body.bgColor="yellow"
}

</script>
</head>
<body onclick="ChangeColor()">
Click on this document!
</body>
</html>

抱歉!评论已关闭.