jQuery Ajax È«½âÎö
±¾ÎĵØÖ·: jQuery Ajax È«½âÎö
±¾ÎÄ×÷ÕߣºQLeelulu
תÔØÇë±êÃ÷³ö´¦£¡
jQueryȷʵÊÇÒ»¸öͦºÃµÄÇáÁ¿¼¶µÄJS¿ò¼Ü£¬ÄÜ°ïÖúÎÒÃÇ¿ìËٵĿª·¢JSÓ¦Ó㬲¢ÔÚÒ»¶¨³Ì¶ÈÉϸıäÁËÎÒÃÇдJavaScript´úÂëµÄÏ°¹ß¡£
·Ï»°ÉÙ˵£¬Ö±½Ó½øÈëÕýÌ⣬ÎÒÃÇÏÈÀ´¿´Ò»Ð©¼òµ¥µÄ·½·¨£¬ÕâЩ·½·¨¶¼ÊǶÔjQuery.ajax()½øÐзâ×°ÒÔ·½±ãÎÒÃÇʹÓõķ½·¨£¬µ±È»£¬Èç¹ûÒª´¦Àí¸´ÔÓµÄÂß¼£¬»¹ÊÇÐèÒªÓõ½jQuery.ajax()µÄ(Õâ¸öºóÃæ»á˵µ½).
1. load
( url, [data], [callback] ) £ºÔØÈëÔ¶³Ì HTML Îļþ´úÂë²¢²åÈëÖÁ DOM ÖС£
url
(String) : ÇëÇóµÄHTMLÒ³µÄURLµØÖ·¡£
data
(Map) : (¿ÉÑ¡²ÎÊý) ·¢ËÍÖÁ·þÎñÆ÷µÄ key/value Êý¾Ý¡£
callback
(Callback) : (¿ÉÑ¡²ÎÊý) ÇëÇóÍê³Éʱ(²»ÐèÒªÊÇsuccessµÄ
)µÄ»Øµ÷º¯Êý¡£
Õâ¸ö·½·¨Ä¬ÈÏʹÓà GET ·½Ê½À´´«µÝµÄ£¬Èç¹û[data]²ÎÊýÓд«µÝÊý¾Ý½øÈ¥£¬¾Í»á×Ô¶¯×ª»»ÎªPOST·½Ê½µÄ¡£jQuery 1.2
ÖУ¬¿ÉÒÔÖ¸¶¨Ñ¡Ôñ·û£¬À´É¸Ñ¡ÔØÈëµÄ HTML Îĵµ£¬DOM Öн«½ö²åÈëɸѡ³öµÄ HTML ´úÂë¡£Óï·¨ÐÎÈç "url #some >
selector"¡£
Õâ¸ö·½·¨¿ÉÒԺܷ½±ãµÄ¶¯Ì¬¼ÓÔØһЩHTMLÎļþ£¬ÀýÈç±íµ¥¡£
ʾÀý´úÂ룺
$(".ajax.load
").load("http://www.cnblogs.com/QLeelulu/archive/2008/03/30/1130270.html .post
",
function
(responseText, textStatus, XMLHttpRequest){
this
;//ÔÚÕâÀïthisÖ¸ÏòµÄÊǵ±Ç°µÄDOM¶ÔÏ󣬼´$(".ajax.load")[0]
//alert(responseText);//ÇëÇ󷵻صÄÄÚÈÝ
//alert(textStatus);//ÇëÇó״̬£ºsuccess£¬error
//alert(XMLHttpRequest);//XMLHttpRequest¶ÔÏó
});
¹ãÖÝ.NET¾ãÀÖ²¿µÄ»î¶¯
½ñÌìÈ¥²Î¼Ó¹ãÖÝ.NET¾ãÀÖ²¿µÄ»î¶¯¡£ÏÂ×ÅëëµÄÓ꣬±¾À´²»ÏëÈ¥ÁË£¬ºóÀ´ÈýÃ÷˵ȥ£¬È»ºó¾ÍÈ¥ÁË¡£
Ö÷Ҫ˵ÁËWPF Silverlight mobile¿ª·¢
È¥µ½µÄʱºò£¬ÒѾ¿ªÊ¼ÁË£¬È˺ܶࡣ
WPFµÄDEMOºÜìÅ°¡£¬¿´µÃÎÒ¶¼ÍêÈ«ÐĶ¯£¬¶ÔÊÓƵµÄÖ§³ÖÒ²·Ç³£ºÃ¡£Óлú»áºÃºÃѧ¡£
Silverlight ½²µÃÒ²²»´í¡£
Åí±óÒÀÈ»ºÜÓÄĬ£¬½²µÄmobile¿ª·¢µÄDEMOºÜ²»´í£¬×Ô¼º¶Ômobile¿ª·¢Ò²ÓÐÄÇôһµãµãµÄÁ˽âÁË¡£
ҪѧµÄ¶«Î÷ºÃ¶à°¡£¡£¡£¡baxia£¡£¡
×÷ÕߣºQLeelulu
³ö´¦£ºhttp://QLeelulu.cnblogs.com/
±¾ÎÄ°æȨ¹é×÷ÕߺͲ©¿ÍÔ°¹²ÓУ¬»¶ÓתÔØ£¬µ«Î´¾×÷ÕßͬÒâ±ØÐë±£Áô´Ë¶ÎÉùÃ÷£¬ÇÒÔÚÎÄÕÂÒ³ÃæÃ÷ÏÔλÖøø³öÔÎÄÁ¬½Ó£¬·ñÔò±£Áô×·¾¿·¨ÂÉÔðÈεÄȨÀû
9
2
0
(ÇëÄú¶ÔÎÄÕÂ×ö³öÆÀ¼Û)
«
ÉÏһƪ£º[ת]¹ØÓÚDOMÔªËض¨Î»ÊôÐÔµÄÉ
Ïà¹ØÎĵµ£º
Ôø¾¶ÔajaxºÜºÃÆ棬ÿ´ÎºÍͬѧ»òÕßͬÊÂ̸ÆðajaxÌýËûÃÇÔÚÄÇÇáÃèµÐ´Ò»·¬²»ÖªËùÒÔÈ»£¬Ç°¼¸Ìì²é×ÊÁϲŻíÈ»Ã÷°×¡£ÏÂÃæÖ±ÈëÕýÌ⣺
Ajax »ù±¾ÉϾÍÊÇ°Ñ JavaScript ¼¼ÊõºÍ XMLHttpRequest
¶ÔÏó·ÅÔÚ Web
±íµ¥ºÍ·þÎñÆ÷Ö®¼ä
¡£µ±Óû§Ìîд±íµ¥Ê±£¬Êý¾Ý·¢Ë͸øһЩ JavaScript ´úÂë¶ø²»ÊÇ
Ö±½Ó·¢Ë͸ø·þÎñÆ÷¡£Ïà·´£¬JavaScript
......
ÔÚʹÓÃJQueryµÄajax·ÃÎÊÒ³Ãæʱ£¬×ÜÊdzö´í£¬µÃ²»µ½·µ»ØµÄhtml´úÂ룬ÓÖ²»ÖªµÀ³öµÄʲô´í£¬°Ù˼²»µÃÆä½â
ÓÚÊǾÍÓÃXMLHTTPÈ¥·ÃÎÊ£¬½á¹ûÒ²³ö´í£¬²»¹ýÄܹ»µÃµ½´íÎóÔÒò£¬È»ºó¸ù¾Ý´íÎóÒòΪȥÍøÉϲ飬ÖÕÓڵõ½Á˴𰸡£¡£
ÔÀ´jspµÄ±àÂëÓëjavaµÄ±àÂë²»Ò»ÖÂ
·½°¸¢Ù
´íÎó
<%@ page contentType="text/html;charset= ......
/*
κÑÔAJAX Àà
ʹÓ÷½·¨:
<mce:script type="text/javascript"><!--
var classAjax = new Ajax(sUrl,sRecvTyp,sQueryString,oResultFunc);
classAjax.post();//post·½Ê½·¢ËÍÊý¾Ý
classAjax.get();//get·½Ê½·¢ËÍÊý¾Ý
//sUrl·¢Ë͵ØÖ·
//sRecvTyp ½ÓÊÜÊý¾ÝÀàÐÍ:0Ϊxml 1Ϊtext
//oResultFunc ·µ»Ø½á¹û´¦Àíº ......
Ç°¼¸ÌìÔÚFirebugÀ©Õ¹¿ª·¢Ò»ÎÄÖоÍÌáµ½¹ýFirephpÕâ¸ö»ùÓÚFirebugµÄ²å¼þ£¬Í¨¹ýʹÓÃFirephpÄã¿ÉÒÔÔÚFirebugµÄConsoleÀ¸Öп´µ½Òªµ÷ÊÔµÄÊý¾Ý£¬¶ø²»Ó°Ïìphp³ÌÐòµÄÕý³£Ö´ÐУ¬ËùÒÔ˵£¬ÕⶫÎ÷¶ÔÓÚAjax¿ª·¢ÊǺÜÓаïÖúµÄ£¡ÏÂÃæÒ»ÆðÀ´¿´ÏÂFirephpµÄʹÓ÷½·¨¡£
µÚÒ»²½£º°²×°
1.Èç¹ûÄãµÄFireFoxûÓÐFirebugÕâ¸ö²å¼þµÄ»°£¬Ê×ÏÈÒª°²×°Fire ......