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¸ñʽµÄÀ´¶ÁÈ¡..µ«ÊÇû³É¹¦²»ÖªµÀÊÇʲôÔÒò¡£
Ïà¹ØÎĵµ£º
ÉÏ´«Ò³ÃæÖ»ÐèÒªÒ»¸öjsÒýÓúÍjsº¯ÊýµÄµ÷Ó㬼òµ¥·½±ã£¬²»Ó°ÏìÍøÒ³ÔÓв¼¾Ö¡£
ÏÂÔØµØÖ·
µ÷ÓÃ˵Ã÷:
1.Ê×ÏÈÒýÓÃjsÎļþ
<script type="text/javascript" src="AienUpload/init.js"></script>
2.½«º¯Êýµ÷ÓÃ(showUpload(boxCtrl,inputCtrl,upPath,maxCount,fn);)°ó¶¨µ½HTMl¿Ø¼þʼþ£¬ÀýÈç
......
Ajax£¬Ñ¡Ôñͬ²½»¹ÊÇÒì²½
AjaxÔÚÍøÒ³ÖÐ×î´óµÄÒ»¸öÓŵãÊÇËü¿ÉÒÔ·ÃÎÊ·þÎñÆ÷ÉϵÄÐÅÏ¢¶ø²»ÐèÒªÖØÐ¼ÓÔØÍøÒ³¡£ÕâÒâζ×ÅÒª¼ìË÷»òÊǸüÐÂÐÅÏ¢µÄijһС¸ö²¿·ÖµÄʱºò£¬Ö»ÐèÒª´Ó·þÎñÆ÷¶Ë´«ËÍÄÇÒ»²¿·ÖÐèÒªµÄÐÅÏ¢¶ø²»ÐèÒªÖØÐÂÏÂÔØÕû¸öÍøÒ³¡£
¡¡¡¡Ajax¿ÉÒÔͨ¹ýÁ½ÖÖ·½·¨·ÃÎÊ·þÎñÆ÷£¬¼´Í¬²½(½Å±¾»áÍ£Áô²¢µÈ´ý·þÎñÆ÷·¢Ëͻظ´È»ºóÔÙ¼ÌÐø)ºÍ ......
===============ÏÂÆAjax
================
ʮһ¡¢µÚʮһ¿Î ===¡· ʹÓÃXHR¶ÔÏó·¢ËͺͽÓÊÜÊý¾Ý
a.¼ÌÐøÉÏÃæ²½Öè
2)×¢²á»Øµ÷º¯Êý,ֻдº¯ÊýÃû³Æ(Èç¹û¼ÓÁËÀ¨ºÅ£¬ÄÇô¾Í°Ñº¯Êý·µ»ØÖµ×¢²á¸ø»Øµ÷º¯Êý)
xmlHttp.onreadystatechange = callback;
3)ÉèÖÃÁ¬½ÓÐÅÏ¢
//µÚÒ»²ÎÊýÊÇHttpÇëÇó·½Ê½£¬Ò»°ãÑ¡Ôñget¡¢pos ......
¡¡[AJAX½éÉÜ]
¡¡¡¡AjaxÊÇʹÓÿͻ§¶Ë½Å±¾ÓëWeb·þÎñÆ÷½»»»Êý¾ÝµÄWebÓ¦Óÿª·¢·½·¨¡£WebÒ³Ãæ²»Óôò¶Ï½»»¥Á÷³Ì½øÐÐÖØÐ¼Ӳ㬾ͿÉÒÔ¶¯Ì¬µØ¸üС£Ê¹ÓÃAjax£¬Óû§¿ÉÒÔ´´½¨½Ó½ü±¾µØ×ÀÃæÓ¦ÓõÄÖ±½Ó¡¢¸ß¿ÉÓᢸü·á¸»¡¢¸ü¶¯Ì¬µÄWebÓû§½çÃæ¡£
¡¡¡¡Òì²½JavaScriptºÍXML£¨AJAX£©²»ÊÇʲôм¼Êõ£¬¶øÊÇʹÓü¸ÖÖÏÖÓм¼Êõ——°ü ......
Ò» ÒýÌâ
ÈçºÎÈÃweb³ÌÐòÓÃÆðÀ´Ïñ×ÀÃæÓ¦ÓóÌÐòÒ»Ñù¼òµ¥£»
ÅÖ¿Í»§¶Ë£¿Êݿͻ§¶Ë£¿ÈçºÎÑ¡Ôñ£¿-----¿´ÐèÇ󣬿´Óû§µÄʹÓã¬Áé»îµ÷½Ú¡£
²»ÒªÉÁ˸£¬¿Õ°×Ò³³öÏÖ£¿
¶þ ³õʶAjax
1. AjaxÊÇÒ»¸ö¿Í»§¶Ë¼¼Êõ£¬²»ÂÛÄãÏÖÔÚʹÓúÎÖÖ·þÎñÆ÷¶Ë¼¼Êõ£¬¶¼ÄÜʹÓÃAjax£¬¶ø²»¹ÜʹÓõÄÊÇJava¡¢.NET¡¢Ruby¡¢PHP»¹ÊÇCGI¡ ......