AJAX ÑéÖ¤Óû§
1´´½¨Á½ÕÅÒ³Ãæ Reg.aspx¡¢CallServer.aspx¡£
ÔÚReg.aspxÒ³ÃæµÄhtmlÖзŠһ¸ö²ãºÍÒ»¸öÎı¾¿ò
<div id="aa">
<asp:TextBox id="txtuser" runat="server" Width="136px"></asp:TextBox>
</div>
<span id="errInfo">ÇëÊäÈëÓû§Ãû</span>
ÔÚReg.aspxÒ³ÃæÖÐдjavascript
¶¨Òå¶þ¸ö±äÁ¿ ¡¢Èý¸öº¯Êý
var xmlhttp=false; //·Å ActiveXObjectµÄʵÀý
var NewsInfo=""; //·Å ×Ö·û´®
function GetXmlHttp()
...{
if(window.ActiveXObject)
...{
try
...{
xmlhttp=new ActiveXObject("Msxml2.XMLHTTP.3.0");
}
catch(e)
...{
try
...{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
catch(e)
...{
NewsInfo="·þÎñÆ÷æ...";
}
}
}
return xmlhttp;
}
function CallServer()
...{
GetXmlHttp();
var struser=document.getElementById("txtuser").value;
if(struser=="" || struser==null)return;
var url="CallServer.aspx?user="+escape(struser);
xmlhttp.onreadystatechange=CallBack;
xmlhttp.open("post",url,true);
xmlhttp.send();
}
function CallBack()
...{
if(xmlhttp.readyState==1)
...{
NewsInfo="Loading...";
}
if(xmlhttp.readyState==4)
...{
var msg=xmlhttp.reponseText;
var spanid=document.getElementById("errInfo");
spanid.innerHTML=msg;
}
}
2ÔÚCallServer.aspxÒ³ÃæµÄpage_loadÖÐдÈçÏ´úÂë
SqlConnection conn=new SqlConnection("server=
Ïà¹ØÎĵµ£º
×î½üÍøÉÏÌáµÄºÜ¶àµÄÒ»¸öиÅÄî¾ÍÊÇ AJAX ÁË, ÄÇô, AJAX ÊÇÊ²Ã´ÄØ? ÒÔÏÂÄÚÈÝÒýÓÃÍøÉÏ×ÊÁÏ:
AJAXÈ«³ÆÎª“Asynchronous JavaScript and XML”£¨Òì²½JavaScriptºÍXML£©£¬ÊÇÖ¸Ò»ÖÖ´´½¨½»»¥Ê½ÍøÒ³Ó¦ÓõÄÍøÒ³¿ª·¢¼¼Êõ¡£ËüÓлúµØ°üº¬ÁËÒÔϼ¸ÖÖ¼¼Êõ£º
Ajax£¨Asynchronous JavaScript + XML£©µÄ¶¨Òå
»ùÓÚ web±ê×¼£¨sta ......
AJAX Ö¸Òì²½ JavaScript ¼° XML£¨Asynchronous JavaScript And XML£©¡£
ÄúÓ¦µ±¾ß±¸µÄ»ù´¡ÖªÊ¶
ÔÚ¼ÌÐøÑ§Ï°Ö®Ç°£¬ÄúÐèÒª¶ÔÏÂÃæµÄ֪ʶÓлù±¾µÄÁ˽⣺
HTML / XHTML
JavaScript
AJAX = Òì²½ JavaScript ¼° XML£¨Asynchronous JavaScript and XML£©
AJAX ²»ÊÇÒ»ÖÖеıà³ÌÓïÑÔ£¬¶øÊÇÒ»ÖÖÓÃÓÚ´´½¨¸üºÃ¸ü¿ìÒÔ¼°½»»¥ÐÔ¸üÇ¿µ ......
1¡¢Ô´´úÂë
Õâ¸öAJAXÁ¬½Ó³Øº¦ÎÒÎÒŪÁ˺ܾã¬ÖÕÓÚ£¬ÈÃËü¼æÈÝIE6/7/8¡¢FireFox¡¢Opera¡¢Google ChromeÕâËÄÀàä¯ÀÀÆ÷ÁË¡£
/**
* AJAX Á¬½Ó³Ø
* AJAXConnectionPool Build in 2009.7.10
* @author CodingMouse
* @version 1.0
*/
var AJAXConnectionPool = function() {
// ÈÎÎñ¶ÓÁÐ
var taskQ ......
Ajax´«²ÎÂÒÂë AjaxÖÐÎÄÂÒÂë ½â¾ö
ÔÚAjax url´«²Îʱ³öÏÖÖÐÎÄÂÒÂëµÄÇé¿ö,½â¾ö·½·¨:
Àý1: xmlHttp.open("GET","Engine.aspx?Action=getmainsort&Type= ......
×¢Ò⣺$.get()ºÍ$.post()·½·¨ÊÇjQueryÖеÄÈ«¾Öº¯Êý¡£Ç°Ãæ½²µ½µÄload()·½Ê½ÊǶÔjQuery¶ÔÏó½øÐвÙ×÷µÄ¡£
1¡¢ $.get()·½·¨
¡¡¡¡$.get()·½·¨Ê¹ÓÃGET·½Ê½À´½øÐÐÒì²½ÇëÇó¡£
¡¡¡¡ËüµÄÓï·¨½á¹¹Îª£º
¡¡¡¡$.get( url [, data] [, callback] [, type] )
¡¡¡¡$.get()·½·¨²ÎÊý½âÊÍÈçÏÂ±í£º
²ÎÊýÃû³Æ
Àà¡¡ÐÍ
˵¡¡¡¡Ã÷
url
Strin ......