ajaxÈýÑÔÁ½Óï(Ö±½Ó½«xmlhttp·µ»ØÖµ½øÐÐjs´úÂë´¦Àí)
ÕâÀïµÄajax¿É²»ÊÇ´óÃû¶¦¶¦µÄajax¾ãÀÖ²¿£¬ ÕâËĸö×ÖĸÔÚÕâÀïAsynchronous JavaScript and XMLµÄËõд¡£Í¨Ë×µØÃèÊöÕâÏî¼¼Êõ¾ÍÊÇ£ºÓà JavaScript Ïò·þÎñÆ÷»ñÈ¡Êý¾Ý£¬È»ºó¸üÐÂÍøÒ³µÄ¾Ö²¿£¬¶ø²»ÊÇË¢ÐÂÕû¸öÍøÒ³¡£
ÕâÏî¼¼Êõ·Ç³£ÊʺÏÓÃÀ´¿ª·¢ÒÔä¯ÀÀÆ÷Ϊ¿Í»§¶ËµÄϵͳµÄ½çÃ棬ʹÓÃajax¸øÓû§´øÀ´µÄ¸üºÃµÄÌåÑ飬ËûÃDz»»á¸Ð¾õµ½ÓÃä¯ÀÀÆ÷¿ª·¢µÄ¿Í»§¶ËÓë×ÀÃæ³ÌÐòÓÐʲô²î±ð¡£
ajaxʹÓÃÁ˱Ƚ϶àµÄjavacript£¬²¢ÐèÒª·ÃÎʺܶàdom¶ÔÏó£¬Õâ³£³£¸ø¿çä¯ÀÀÆ÷·ÃÎÊ´øÀ´À§ÈÅ¡£µ«¼ÙÈçÄãСÐÄÓ¦¶Ô£¬»¹ÊÇÈÝÒ×½â¾öÕâ¸öÎÊÌâµÄ¡£±ÈÈ磬ÄãÏë´Ó·þÎñÆ÷¶Î»ñµÃһЩÊý¾Ý£¬Äã±ØȻҪÓõ½xmlhttp£¬ÎªÁËÈóÌÐòä¯ÀÀÆ÷Î޹أ¬Äã¿ÉÒÔÕâÑù´´½¨xmlhttp¶ÔÏó£º
//for IE
var xmlhttp=false;
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) {
xmlhttp = false;
}
}
//for firefox
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
xmlhttp = new XMLHttpRequest();
}
ÔںܶàµÄajax·¶ÀýÖУ¬¿ª·¢Õ߶¼ÊÇÓÃxmlhttp´Ó·þÎñÆ÷¶Ë»ñµÃÒ»¸öxmlÊý¾Ý£¬È»ºóת»»³Éjavascript¿É´¥¼°µÄ¶ÔÏó£¬ÔÙÓÃjs»æÖƵ½documentÖС£µ«ÎÒ¾õµÃÕâ²¢·ÇΨһѡÏÎÒÉõÖÁ¾õµÃÊǶà´ËÒ»¾Ù£¡ÎªÊ²Ã´²»Ö±½Ó´«µÝjs¶ÔÏóÄØ£¿ÔÚÎÒ¿ª·¢µÄϵͳÖУ¬xmlhttp´Ó·þÎñÆ÷ÉÏ»ñµÃµÄÊÇ´ú±íjs¶ÔÏóµÄ×Ö·û´®¡£¼ÙÈçÎÒÒª´«ËÍÒ»¸öÈËÔ±ÁÐ±í£¬ÎÒ»áÔÚ·þÎñÆ÷ÉÏÊä³ö£º
[{id:1,name:"hexiaodong"},{id:2,name:"mary"},{id:3,name:"name"},...]}
È»ºóÔÚä¯ÀÀÆ÷ÉÏÓÃjs»ñµÃÕâ¸ö×Ö·û´®Ëù´ú±íµÄ¶ÔÏó£º
var returned = xmlhttp.responseText;
var obj = eval(returned );
½Ó×Å£¬Äã¾Í¿ÉÒÔÕâÑù·ÃÎÊ£º
var person1 = obj[0]; var person2 = obj[1];
alert(person1.id);
alert(person1.name);
ÕâÑù×öȷʵÊÇÓÖ¼òµ¥ÓÖ½ÚÔ¼×ÊÔ´
²»¹ýÎÒÒ»Ö±ÏëÓÃxml¸ñʽµÄÀ´¶ÁÈ¡..µ«ÊÇû³É¹¦²»ÖªµÀÊÇʲôÔÒò¡£
Ïà¹ØÎĵµ£º
¡¡¡¡Ê×Ïȼì²éWeb.configÎļþÀïÊÇ·ñÊÇÈçÏ´úÂ룺
¡¡¡¡´ò¿ªVS2005´´½¨ÐÂÏîÄ¿£¬Ñ¡ÔñASP.NET¡¡AJAXÏîÄ¿£¬È»ºó°Ñ¸ÃÏîÄ¿Web.configÎļþµÄÄÚÈÝÈ«²¿¸´ÖƵ½Ä㱨´íµÄWeb.configÎļþÀï¡£
¡¡¡¡Èç¹ûÕâ¸ö°ì·¨Î´Äܽâ¾ö°ì·¨Çë²é¿´¸ÃÏîÄ¿¸ùĿ¼µÄBinÎļþ¼ÐÄÚÊÇ·ñÓÐSystem.Web.Extensions.Design.dll¡¢System.Web.Extensions.dll¡¢A ......
+++++++++++++++++++++++Ajax
~~~~~~~~~~~~~~~~~~~~~~~~~~
======= Ajax ¼¼Êõ ========
Ò»¡¢µÚÒ»¿Î ===¡· AJAX¸ÅÊöÓëIntelliJ°²×°
a.Ajax¶Á·¨Æäʵ²»ÊÇÎÒÃǶÁµÄ'°¢¼Ù¿Í˹'£¬×¢Òâרҵ»¯¡£
b.ÍõÐË¿ýÀÏʦÏȽ²Êµ¼ùÔÙ½²ÀíÂÛ¡£
c.¿ª·¢¹¤¾ß²»ÔÙÊÇeclipseÁË£¬ÒòΪajaxÖ÷Ҫдjavascript
d ......
1¡¢PHP·¢ËÍÖÐÎÄ¡¢Ajax½ÓÊÕ
Ö»ÐèÔÚphp¶¥²¿¼ÓÈëÒ»¾ä£º
header('Content-type: text/html;charset=GB2312');
xmlHttp»áÕýÈ·½âÎöÆäÖеÄÖÐÎÄ¡£
2¡¢Ajax·¢ËÍÖÐÎÄ¡¢PHP½ÓÊÕ
Õâ¸ö±È½Ï¸´ÔÓ£º
AjaxÖÐÏÈÓÃencodeURIComponent¶ÔÒªÌá½»µÄÖÐÎĽøÐбàÂë
PHPÖУº
$GB2312string=iconv( ‘UTF-8′, ‘gb2312//I ......
ʵÏÖ×¢²á½çÃæÎÞË¢ÐÂÅжÏÖØÃû£¬ÓÉÓÚÒª·ÃÎÊÊý¾Ý¿â£¬ËùÒÔÒª´ïµ½ÎÞˢУ¬Ö»ÄÜÓÃAjax¼¼Êõ¡£
ÆäÖÐ×îÖØÒªµÄ¾ÍÊÇxmlHttp¶ÔÏó¡£
XmlHttpÊÇʲô£¿
×îͨÓõĶ¨ÒåΪ£ºXmlHttpÊÇÒ»Ì׿ÉÒÔÔÚJavascript¡¢VbScript¡¢JscriptµÈ½Å±¾ÓïÑÔÖÐͨ¹ýhttpÐÒé´«ËÍ»ò´Ó½ÓÊÕXML¼°ÆäËûÊý¾ÝµÄÒ»Ì×API¡£XmlHttp×î´óµÄÓô¦ÊÇ¿ÉÒÔ¸üÐÂÍøÒ³µ ......
ǰ̨´úÂ룺
<head runat="server">
<title>ÎÞ±êÌâÒ³</title>
<script src="Ajax.js" type="text/javascript"></script>
</head>
<body>
<form id="form1" runat="server">
<div&g ......