<input type="button" onclick="ajaxTest()" value="AJAX²âÊÔ">
<input type="button" onclick=" document.getElementById('weather').innerHTML='' " value="Òþ²Ø">
<mce:script type="text/javascript"><!--
// 1. ³õʼ»¯ ÇëÇó ¶ÔÏó
// Mozilla/Firefox 쵀
//var xmlhttp = new XMLHttpRequest();
// IE 쵀
var xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
//alert(xmlhttp);
function ajaxTest() {
// Ö¸¶¨Òª´ò¿ªµÄÒ³Ãæ
xmlhttp.open("GET", "staticpage.html", true);// HTTP ÇëÇóµÄ·½Ê½, URL, ÊÇ·ñÒì²½
// Ö¸¶¨Ò³Ãæ´ò¿ªÍêÖ®ºóÒª½øÐеIJÙ×÷.
xmlhttp.onreadystatechange = mychange;
// ¿ªÊ¼·¢Æðä¯ÀÀÇëÇó, Mozilla ±ØÐë¼Ó null
xmlhttp.send(null);
}
// Õâ¸öº¯Êý¾ÍÊÇÿ´Î״̬¸Ä±äÒªµ÷Óõĺ¯Êý
function mychange() {
// ÇëÇóÒÑÍê³É
if(xmlhttp.readyState == 4) {
//alert(xmlhttp.readyState);
// alert(xmlhttp.responseText);
// ¸üжÔÓ¦µÄ HTML ÔªËØÀ ......
ÆäʵajaxµÄ¶«Î÷²»ÊǺÜÊìϤ£¬¶øÇÒ¶ÔÓÚjavascriptÕâÑùÁãËéµÄÓïÑÔʵÔÚÊǺܿ¹¾Ü¡£ÓÚÊǹýÈ¥Ò»Ö±¶¼ÌÓ±ÜËü£¬ÆÈÓÚÏîÄ¿µÄѹÁ¦£¬²»µÃÒÑΩÓÐÓ²ÅöÓ²ÁË¡£ÎªÁË¿ìËÙÉÏÊÖ£¬Ö®Ç°×öÁ˼¸¸öСʵÑ飬´úÂëʵÔÚÌ«¶àÁË¡£ÐÒºÃstruts2ÌṩÁËһЩajaxµÄ¼òÒ×ʵÏÖ¡£
¸úÍøÉÏËùÓеĽ̳ÌÒ»Ñù£¬ÏÈ´Ó×î¼òµ¥µÄ¿ªÊ¼°É~
ÔÚÍ·½áµã¼ÓÉÏ<s:head theme="ajax"/>
È»ºó
<s:url id="requesturl" value="/get.action"></s:url>
<s:div id="information" theme="ajax"></s:div>
<s:a targets="information" theme="ajax" href="%{requesturl}" mce_href="%{requesturl}">»ñÈ¡ÐÅÏ¢</s:a>
·þÎñÆ÷¶ËµÄ´úÂëÎҾͲ»Ð´ÁË£¬´óͬСÒì¡£·µ»ØµÄ¿ÉÒÔÊÇÈκζ«Î÷£¬¸÷ÖÖ±íµ¥¡¢±í¸ñ¡¢Í¼Ê²Ã´µÄ£¬¾ßÌåÒª¿´ÄãÇëÇóµÄÊÇʲô¡£·µ»ØµÄ×ÊÔ´»áÖ±½ÓÏÔʾÔÚinformationµÄdivÖС£ÕâÀïÓиöСÎÊÌâҪעÒ⣬requesturlÖеÄvalueÖµ±ØÐëÊÇ/*.actionµÄÐÎʽ£¬¶ø²»ÄÜÊÇstruts.xmlÖеĶÔÓ¦µÄactionÃû³Æ¡£
¹ØÓÚÆäËûµÄÊôÐԾͲ»ÊµÑéÁË¡£
½ÓÏÂÀ´¼ÓÉÏÒ»µãjavascriptµÄ²Ù×÷£¬ÓÃÎı¾°´Å¥²Ù×÷·µ»Ø×ÊÔ´µÄÏÔʾºÍÒþ²Ø¡£
ÓÚÊǺÜ×ÔÈ»µÄÏëµ½ÕâÑùд£º
<mce:script type="text/javascript"><!--
function hi ......
ÓõıêÇ©ÓÐScriptManager£¬UpdatePanel£¬UpdateProgress £¬Ö÷ÒªµÄÊÇUpdatePanelÖеÄTriggersÊôÐÔÒ»¶¨Òª¶Ô¡£
ǰ̨´úÂë
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:TextBox ID="txtName" runat="server" OnTextChanged="txtName_TextChanged" AutoPostBack="true" ></asp:TextBox>
<asp:Literal ID="ltlName" runat="server" ></asp:Literal>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="txtName" EventName="TextChanged" />
</Triggers>
</asp:UpdatePanel>
<asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="UpdatePanel1">
<ProgressTemplate>
......
APS.NETÒ¹»°µÄÀý×Ó¼ÓÔغ󱨴íÈçÏ£º
System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35´íÎó
ÔÒòÊÇδÄܼÓÔØÎļþ»ò³ÌÐò¼¯ system.web.extensions
½â¾ö°ì·¨:
1,Èç¹ûÄãµÄ³ÌÐòÔËÐÐÔÚÄãÄÜ¿ØÖƵķþÎñÆ÷ÉÏ£¬ÄÇô°²×°asp.net ajax¾ÍÐÐÁË£¬ÕâÊÇSystem.Web.ExtensionsµÈdll×öΪGAC²¿Êð£»
ÏÈÏÂÔØASP.NET°²×°Îļþ£¬ÃûΪASPAJAXExtSetup.msiµÄ°²×°Îļþ¡£
2.ÏÂÔØAJAX¿Ø¼þÀ©Õ¹¿â£¬ÏÂÔØÒ³Ã棬´ò¿ªºó¸ù¾Ý.NET frameworkÊÇ2.0»¹ÊÇ3.5Ñ¡ÔñÏà¹ØµÄ°æ±¾ÏÂÔØ£¬±¾ÈËÊÇ2.0µÄ
AjaxControlToolkit.zip .NET framework 2.0
AjaxControlToolkit-Framework3.5.zip .NET framework 3.5
Ϻúó¾Í½âѹµ½Ò»¸öÎļþ¼ÐÖÐ,ÎÒ¾õµÃ»¹Êǽâѹµ½vsµÄ°²×°Ä¿Â¼»òÕ߱Ƚϰ²È«µãµÄµØ·½,ÃâµÃÒÔºóÎóɾÁË.¿´Ò»ÏÂÀïÃæµÄÎļþ¼Ð,¼ÇסÁ½¸öÖØÒªµÄÎļþ¼ÐŶ,Ò»¸öÊÇBinaries Ò»¸öÊÇSampleWebSiteϵÄbin ,ÏÈ¿´¿´binϵĶ«Î÷,ÀïÃæÊDz»ÊÇÓкܶàÎļþ¼ÐŶ, ......
APS.NETÒ¹»°µÄÀý×Ó¼ÓÔغ󱨴íÈçÏ£º
System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35´íÎó
ÔÒòÊÇδÄܼÓÔØÎļþ»ò³ÌÐò¼¯ system.web.extensions
½â¾ö°ì·¨:
1,Èç¹ûÄãµÄ³ÌÐòÔËÐÐÔÚÄãÄÜ¿ØÖƵķþÎñÆ÷ÉÏ£¬ÄÇô°²×°asp.net ajax¾ÍÐÐÁË£¬ÕâÊÇSystem.Web.ExtensionsµÈdll×öΪGAC²¿Êð£»
ÏÈÏÂÔØASP.NET°²×°Îļþ£¬ÃûΪASPAJAXExtSetup.msiµÄ°²×°Îļþ¡£
2.ÏÂÔØAJAX¿Ø¼þÀ©Õ¹¿â£¬ÏÂÔØÒ³Ã棬´ò¿ªºó¸ù¾Ý.NET frameworkÊÇ2.0»¹ÊÇ3.5Ñ¡ÔñÏà¹ØµÄ°æ±¾ÏÂÔØ£¬±¾ÈËÊÇ2.0µÄ
AjaxControlToolkit.zip .NET framework 2.0
AjaxControlToolkit-Framework3.5.zip .NET framework 3.5
Ϻúó¾Í½âѹµ½Ò»¸öÎļþ¼ÐÖÐ,ÎÒ¾õµÃ»¹Êǽâѹµ½vsµÄ°²×°Ä¿Â¼»òÕ߱Ƚϰ²È«µãµÄµØ·½,ÃâµÃÒÔºóÎóɾÁË.¿´Ò»ÏÂÀïÃæµÄÎļþ¼Ð,¼ÇסÁ½¸öÖØÒªµÄÎļþ¼ÐŶ,Ò»¸öÊÇBinaries Ò»¸öÊÇSampleWebSiteϵÄbin ,ÏÈ¿´¿´binϵĶ«Î÷,ÀïÃæÊDz»ÊÇÓкܶàÎļþ¼ÐŶ, ......
web2.0ºá¿Õ³öÊÀ£¬ajaxÊ×µ±Æä³å£¬½ñÌì×öwebµÄÈç¹ûÔÙ²»Ñ§µãajaxµÄ»°£¬¾ÍÏÔµÄÂäÎéÁË£¬¶øѧajaxµÄÓõĻ·¾³Èç¹ûÊÇasp.net£¬ÄÇajax.netÄã¾Í²»µÃ²»Ñ§ÁË¡£Ê×ÏȾÍÊÇ»·¾³µÄÅäÖã¬ÈçÏÂ
vs2005+sql2005+Winxp sp2+ie6.0+Office2003»·¾³ÉèÖÃÈçÏ£º
ÏÂÔØÍê ASPAJAXExtSetup.msi °²×°¸üкóÔÚÄãµÄϵͳÅÌϵģ¨ÒÔCÅÌΪÀý£© ³öÏÖÕâ¸ö Îļþ¼Ð£º
C:\Program Files\Microsoft asp.NET\ASP.NET 2.0 ajax Extensions\v1.0.61025
°²×°Õâ¸öºóÎÒÃǾͿÉÒÔ´´½¨Asp.net AJAXEnabledWebSiteÕ¾µãÁË£¬ÕâÆäʵ¾ÍÊǸöajax.netÍøÕ¾µÄÄ£°å¡£µ«ÊÇÎÒÃÇÏÖÔÚ»¹²»ÄÜʹÓÃ΢Èí¸øÎÒÃÇ¿ª·¢ºÃµÄajax¿Ø¼þ ¡£ÒªÏëÖªµÀÔõôʹÓÃajax.net¿Ø¼þÍùÏ¿´¡£
ÏÂÔØAjaxControlToolkit £¬ÉÏÃæÁ½¸öÒ»¸öÊÇ´øÔ´´úÂëµÄ Ò»¸öÊDz»´øÔ´´úÂëµÄtoolkit¡£½¨ÒéÏÂÔØ´øÔ´´úÂëµÄ toolkit¡£ÏÂÔØÍê³Éºó°Ñ¸ÃÎļþ½âѹµ½£º
C:\Program Files\Microsoft asp.NET\ASP.NET 2.0 ajax Extensions\v1.0.61025\AjaxContronlToolkit\
Ë«»÷ÔËÐÐAjaxControlToolkit.sln¡£
ÓÃvs2005´ò¿ªÕâ¸ösln£¬±àÒëTemplateVSIÕâ¸öÏîÄ¿ºó£¬°ÑÔÚC:\Program Files\Microsoft asp.NET\ASP.NET 2.0 AJAX Extensions\SampleWebSite\BinÏÂÃæÉú³ÉµÄAjaxControlToolkit.dllºÍAjaxContro ......
ÔÚʹÓÃjQuery µÄAjax¼ÓÔØÊý¾ÝÊÇ Èç¹ûʹÓÃget·½Ê½´«µÝ²ÎÊýÔò´æÔÚÒ»ÏÂÎÊÌâ
firefoxÏ´«µÝÊý¾ÝÕý³£
ieÏÂÔò»á³öÏÖ»º´æÎÊÌâ
½â¾ö·½·¨£º
1¡¢http://yourwebsite?parseInt(Math.random() * 1000) ÔÚurlºóÃæ¼ÓÉÏÒ»¸öËæ¼´Êý£¬ÕâÑùÿ´Î·¢Ë͵ľͲ»Ò»ÑùÁË£¬¶øÇÒ²»Ó°ÏìÄãµÄ¹¦ÄÜ.
2¡¢Ê¹ÓÃpost´«µÝ²ÎÊý
......