Ò»¸öÆÊÎöAJAXÔÀíµÄ¼òµ¥·¶Àý
ΪÁËÈø÷ΪÄܹ»Á˽âʲôÊÇAJAX£¬ÒÔÏÂÊÇÒ»¸öAJAXµÄÊÖ¹¤·¶Àý£¨¼´²»ÒýÓÃÈκεÄLibrary»òAJAX
framework£©£¬´Ë·¶ÀýÆÄΪ¾«ÒªÒ׶®£¬Æä×÷ÓÃÖ÷ÒªÊÇ͸¹ýClient ¶ËµÄBrowserÀ´¼´Ê±¼à¿ØWeb ·þÎñÆ÷×ÊÔ´»òЧÄܱ仯£¬¸÷λֻҪ×ö¹ý
Ò»±é·¶Àý¾ÍÄܹ»Á˽âAJAXÔÚÍøÒ³¿ª·¢ÉÏÊǶàô¾ßÓÐÍþÁ¦ÁË¡£
ÏÈÀ´¿´¿´Ð§¹ûͼ£º
±¾·¶ÀýÊÇÒ»¸ö¼òµ¥µÄAJAXÀý×Ó£¬µ«ÂéȸËäСÎåÔà¾ãÈ«£¬¿ÉÓÉ´Ë¿ú¼ûÔʼAJAX·Çͬ¼¼ÊõÊÇÈçºÎÔË×÷¡£²»ÐèÒª°²×°ÈκÎÌØÊâµÄAJAXÌ×¼þ£¬²½Öè˵Ã÷ÈçÏ£º
Ò»¡¡½¨Á¢WebÏîÄ¿
Ê×ÏÈÔÚVS 2005£¨»òVS.NET 2003£©½¨Á¢Ò»¸öÆÕͨµÄWEBÏîÄ¿£¬»òÕßÄúûÓÐVS¿ª·¢¹¤¾ß£¬Ö±½ÓÓüÇʱ¾½¨Á¢Ò²ÐС£
¶þ¡¡½¨Á¢Client¶ËÒ³Ãæ
ÔÚWebר°¸ÖмÓÈëÒ»¸öClient¶ËÒ³ÃæClient.htm£¬²¢½«´ËÒ³ÃæÉ趨ΪÆðʼҳ£¬Õâ¸öÒ³Ãæ»áÏòWebËÅ·þÆ÷ÍøÒ³·¢³ö·Çͬ²½ºô½ÐÇëÇ󣬲¢ÇÒ½«ËÅ·þ
Æ÷»Ø´«×ÊÁϸüе½ÍøÒ³ÔªËØÖУ¬´úÂëÈçÏ£º
<!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¶Ë´¦Àí³Ìʽ
ÁíÍâÔÚר°¸ÖмÓÈëÒ»¸öServer.aspxÍøÒ³£¨º¬.cs£©£¬Server.aspx²»ÐèÒªÌí¼ÓÈκδúÂë¡£
Server.aspx.cs ³ÌÐòÂëÈçÏ£º
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&
Ïà¹ØÎĵµ£º
½â¾öAJAX(JSP)ÖÐÎÄÂÒÂë»òÌØÊâ·ûºÅ£¨&£©µÄ´«µÝÎÊÌâ----> ±¾ÈËÔ´´£¨244796562@qq.com£©
************************js******************************
...
...
var s = encodeURIComponent("ÖÐÎÄ&English&@#$%!");
xmlReq.send("test", "txt=" + s, callback, callerror);//ͨ¹ýXMLHTTPRequest·¢ËÍ×Ö·ûÊý¾ ......
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="LeftMenu.aspx.cs" Inherits="_Default" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xht ......
AjaxSuggest.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="AjaxSuggest.aspx.cs" Inherits="AjaxSuggest" %>
<!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/199 ......
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript&quo ......