jQuery Ajax È«½âÎö
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¶ÔÏó
});
ÕâÀォÏÔʾ½á¹û¡£
×¢£º²»ÖªµÀΪʲôURLд¾ø¶Ô·¾¶ÔÚFFÏ»á³ö´í£¬ÖªµÀµÄÂé·³¸æËßÏ¡£ÏÂÃæµÄget()ºÍpost()ʾÀýʹÓõÄÊǾø¶Ô·¾¶£¬ËùÒÔÔÚFFÏÂÄ㽫»á³ö´í²¢²»»á¿´µ½·µ»Ø½á¹û¡£»¹ÓÐget()ºÍpost()ʾÀý¶¼ÊÇ¿çÓòµ÷Óõģ¬·¢ÏÖ´«ÉÏÀ´ºóû°ì·¨»ñÈ¡½á¹û£¬ËùÒÔ°ÑÔËÐа´Å¥È¥µôÁË¡£
2. jQuery.get( url, [data], [callback] )£ºÊ¹ÓÃGET·½Ê½À´½øÐÐÒì²½ÇëÇó
²ÎÊý£º
url (String) : ·¢ËÍÇëÇóµÄURLµØÖ·.
data (Map) : (¿ÉÑ¡) Òª·¢Ë͸ø·þÎñÆ÷µÄÊý¾Ý£¬ÒÔ Key/value µÄ¼üÖµ¶ÔÐÎʽ±íʾ£¬»á×öΪQueryString¸½¼Óµ½ÇëÇóURLÖС£
callback (Function) : (¿ÉÑ¡) ÔØÈë³É¹¦Ê±»Øµ÷º¯Êý(Ö»Óе±ResponseµÄ·µ»Ø״̬ÊÇsuccess²ÅÊǵ÷Óø÷½·¨)¡£
ÕâÊÇÒ»¸ö¼òµ¥µÄ GET ÇëÇó¹¦ÄÜÒÔÈ¡´ú¸´ÔÓ $.ajax ¡£ÇëÇó³É¹¦Ê±¿Éµ÷Óûص÷º¯Êý¡£Èç¹ûÐèÒªÔÚ³ö´íʱִÐк¯Êý£¬ÇëʹÓà $.ajax¡£Ê¾Àý´úÂ룺
Ïà¹ØÎĵµ£º
ת£ºhttp://hi.baidu.com/playkk/blog/item/9b5f99952fb4c94fd0135e0c.html
1¡¢Ajax.net ×öΪAjax¼¼ÊõÔÚdotNet ¿ò¼ÜϵÄʵÏÖ£¬×÷ÕßMichael Schwarz²ÉÈ¡ÁËÒ»ÖÖ·âװЧ¹ûÏ൱°ôµÄ¼¼Êõ£º½«¿Í»§¶Ë´¦ÀíXML¡¢Ê¼þµ÷Ó÷½Ê½¶¼·â×°ÔÚ2¸öJavascriptÎļþÖУ¨AjaxPro.prototype.js ºÍAjaxPro.core.js£©£¬Í¬Ê±½«Õâ2¸öÖØÒªÎļþÒÔ×ÊÔ´µÄÐ ......
11ÔÂ21ÈÕÍí£·µãÓ¦ÑûÔÚÎ人´óѧÐÅϢѧԺ×öÁËÒ»³¡¹ØÓÚASP.NETÏÂAJAX¿ª·¢µÄ±¨¸æ£¬ÒÔÎÒ×Ô¼º¾Àú½²ÊöÁËһЩÌØÊâÓ¦ÓÃÔÚ¹ýÈ¥µ½ÏÖÔÚʵÏÖÊֶεı仯£¬±¾À´Ïë»Ø¼ÒÖ®ºó×ö¸ö×ܽáµÄ£¬µ«ÊÇÓÉÓÚ×î½üÒÔÀ´ÊÂÇéÒ»Ö±ºÜ¶à£¬ËùÒÔûÓÐÀ´µÃ¼°×ܽᡣ½ñÍíµÃÒÔÓпÕ×ܽáһϡ£
AJAX½éÉÜ
ÆäʵAJAXÓ¦ÓÃµÄ ......
XMLHttpRequest ¶ÔÏóÊÇAJAX¹¦ÄܵĺËÐÄ£¬Òª¿ª·¢AJAX³ÌÐò±ØÐë´ÓÁ˽âXMLHttpRequest ¶ÔÏó¿ªÊ¼¡£
Á˽âXMLHttpRequest ¶ÔÏó¾ÍÏÈ´Ó´´½¨XMLHttpRequest ¶ÔÏó¿ªÊ¼£¬ÔÚ²»Í¬µÄä¯ÀÀÆ÷Öд´½¨XMLHttpRequest ¶ÔÏóʹÓò»Í¬µÄ·½·¨£º
ÏÈ¿´¿´IE´´½¨XMLHttpRequest ¶ÔÏóµÄ·½·¨£¨·½·¨1£©£º
var xmlhttp = new ActiveXObject("Msxml2.XMLH ......
AjaxÌí¼ÓÊý¾ÝÖ®ºó£¬Ë¢ÐÂǰ̨ҳÃ棬Êý¾ÝûÓб仯¡£
Ö»ÓÐÖØÐÂÕÒ¿ªIEÔÙÊäÈëµØÖ·£¬²ÅÄÜ¿´µ½Ð§¹û¡£
ÒÔÉÏÕâЩÊDz»ÊÇ»º´æµÄÔÒò°¡£¿Ôõô½â¾ö£¿
ajax»º´æÎÊÌâ½â¾ö;¾¶£º
1.ÔÚAJAXÇëÇóµÄÒ³Ãæºó¼Ó¸öËæ»úº¯Êý,ÎÒÃÇ¿ÉÒÔʹÓÃËæ»úʱ¼äº¯Êý
¼Óʱ¼ä´Á var url = BaseURL + "&timeStamp=" ......
Ïò´ó¼ÒÍƼö10¸öÏ൱°ôµÄAjaxºÍJavascript¹úÍâ×ÊÔ´ÍøÕ¾»ò²©¿Í£¬ËüÃÇÌṩÁËÏ൱¶àµÄ¸ßÖÊÁ¿Ajax¡¢JavascriptʵÀý¼°½Ì³Ì£¬Ï²»¶AjaxºÍJavascriptµÄÅóÓѾø¶Ô²»ÄÜ´í¹ý¡£
1.Ajax Rain
AjaxRainÓкܶàÍêÃÀÕûºÏAJAX, CSS, DHTML »ò JavascriptµÄʵÀý£¬ÓÐһЩDemoµÄÈ·ÖµµÃÄãÈ¥¿´Ò»¿´£¬¼´Ê¹Äã²»ÊÇÍøÒ³Éè¼Æ(¿ª·¢)ʦ¡£
Ajax/Javascri ......