¼òµ¥µÄAJAXÊÖ¹¤·¶Àý
Client¶Ë
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<script language="javascript">
var XmlHttp=new ActiveXObject("Microsoft.XMLhttp");
function sendAJAX()
{
XmlHttp.Open("POST","Server.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>
Áí½¨Ò»Ò³ÃæServer.aspx£¬Server¶Ë
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Diagnostics;
public partial class Server : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
PerformanceCounter myMemory = new PerformanceCounter();
myMemory.CategoryName = "Memory";
myMemory.CounterName = "Available KBytes";
string txtResult = "-->·þÎñÆ÷¿ÉÓÃÄÚ´æ´óС£º" + myMemory.NextValue().ToString();
Response.Write(DateTime.Now.ToLongTimeString() + txtResult);
}
}
Syst
Ïà¹ØÎĵµ£º
AJAXÎÞÒÉÊÇ2005Äê³´µÄ×îÈȵÄWeb¿ª·¢¼¼ÊõÖ®Ò»£¬µ±È»£¬Õâ¸ö¹¦ÀÍÀë²»¿ªGoogle¡£ÎÒÖ»ÊÇÒ»¸öÆÕͨ¿ª·¢Õߣ¬Ê¹ÓÃAJAXµÄµØ·½²»ÊÇÌرð¶à£¬ÎҾͼòµ¥µÄ°ÑÎÒʹÓõÄÐĵÃ˵һÏ¡££¨±¾ÎļÙÉèÓû§ÒѾ¾ßÓÐJavaScript¡¢HTML¡¢CSSµÈ»ù±¾µÄWeb¿ª·¢ÄÜÁ¦£©
¡¡¡¡[AJAX½éÉÜ]
¡¡¡¡AjaxÊÇʹÓÿͻ§¶Ë½Å±¾ÓëWeb·þÎñÆ÷½»»»Êý¾ÝµÄWebÓ¦Óÿª·¢·½·¨¡£WebÒ³ ......
AJAX Ö¸Òì²½ JavaScript ¼° XML£¨Asynchronous JavaScript And XML£©¡£
ÄúÓ¦µ±¾ß±¸µÄ»ù´¡ÖªÊ¶
ÔÚ¼ÌÐøѧϰ֮ǰ£¬ÄúÐèÒª¶ÔÏÂÃæµÄ֪ʶÓлù±¾µÄÁ˽⣺
HTML / XHTML
JavaScript
AJAX = Òì²½ JavaScript ¼° XML£¨Asynchronous JavaScript and XML£©
AJAX ²»ÊÇÒ»ÖÖеıà³ÌÓïÑÔ£¬¶øÊÇÒ»ÖÖÓÃÓÚ´´½¨¸üºÃ¸ü¿ìÒÔ¼°½»»¥ÐÔ¸üÇ¿µ ......
JSON²å¼þÌṩÁËÒ»ÖÖÃûΪjsonµÄResultType£¬Ò»µ©ÎªÄ³¸öActionÖ¸¶¨ÁËÒ»¸öÀàÐÍΪjsonµÄResult£¬Ôò¸ÃResultÎÞÐèÓ³Éäµ½ÈκÎÊÓͼ×ÊÔ´¡£ÒòΪJSON²å¼þ»á¸ºÔð½«ActionÀïµÄ״̬ÐÅÏ¢ÐòÁл¯³ÉJSON¸ñʽµÄÊý¾Ý£¬²¢½«¸ÃÊý¾Ý·µ»Ø¸ø¿Í»§¶ËÒ³ÃæµÄJavaScript¡£
¡¡¡¡¼òµ¥µØ˵£¬JSON²å¼þÔÊÐíÎÒÃÇÔÚJavaScriptÖÐÒì²½µ÷ÓÃAction£¬¶øÇÒAction²»ÔÙÐè ......
Ajax´«²ÎÂÒÂë AjaxÖÐÎÄÂÒÂë ½â¾ö
ÔÚAjax url´«²Îʱ³öÏÖÖÐÎÄÂÒÂëµÄÇé¿ö,½â¾ö·½·¨:
Àý1: xmlHttp.open("GET","Engine.aspx?Action=getmainsort&Type= ......
AJAXÂÒÂë½â¾ö
ÓùýAJAXµÄÅóÓѿ϶¨ÖªµÀjavascriptÊÇʹÓÃUTF-8¹ú¼Ê±àÂ룬¼´Ã¿¸öºº×ÖÓÃ4¸ö×Ö½ÚÀ´´æ´¢£¬µ«ÊÇÕâ¾ÍÔì³ÉÁËÓÃAJAXÀ´sendÊý¾ÝµÄʱºò³öÏÖÂÒÂë¡£
AjaxÂÒÂë²úÉúÖ÷ÒªÓÐ2¸öÔÒò
1. xtmlhttp ·µ»ØµÄÊý¾ÝĬÈϵÄ×Ö·û±àÂëÊÇutf-8£¬Èç¹ûǰ̨ҳÃæÊÇgb2312»òÕßÆäËü±àÂëÊý¾Ý¾Í»á²úÉúÂÒÂë
2. post·½·¨Ìá½»Êý¾Ý ......