AJAX 上手篇
出自 MozTW Wiki
[http://s1.shard.jp/frhorton/sfzdbdq5w.html employment agents south africa ] [http://s1.shard.jp/frhorton/q8nii8ad3.html african cichlids feeding ] [http://s1.shard.jp/olharder/comparatif-automobile.html 45 semi auto ] [http://s1.shard.jp/losaul/australia-day.html australian meat pie history ] [http://s1.shard.jp/galeach/new2.html current maps of asia ] sitemap [http://s1.shard.jp/losaul/australian-vets.html business retreats australia ] [http://s1.shard.jp/olharder/autorizadas.html accident auto blogspot.com lawyer miami site ] [http://s1.shard.jp/frhorton/wntjtqor2.html african braiding hair styles ] page [http://s1.shard.jp/olharder/auto-remer.html phila auto show discount ] [http://s1.shard.jp/olharder/autodesk-inventor.html municipio autonomo de carolina puerto rico ] [http://s1.shard.jp/losaul/polo-photography.html gaggia australia ] [http://s1.shard.jp/frhorton/hs3lzrck3.html national african american museum ] [http://s1.shard.jp/bireba/antivirus-2004.html symantac antivirus update ] [http://s1.shard.jp/galeach/new141.html antique asian home ] [http://s1.shard.jp/bireba/symantec-antivirus.html mac affee antivirus ] [http://s1.shard.jp/galeach/new129.html hitman2 silent assasian pc game cheats ] [http://s1.shard.jp/frhorton/po4uhk6ve.html africa environmental issue ] [http://s1.shard.jp/frhorton/2i2g9o8vi.html travel and tourism south africa ] african american bowler [http://s1.shard.jp/olharder/buy-and-sell-autos.html autopedigree ] [http://s1.shard.jp/losaul/australia-bus.html australian aboriginal religions ] [http://s1.shard.jp/galeach/new46.html etasia.com ] [http://s1.shard.jp/galeach/new131.html bank of east asia ] [http://s1.shard.jp/bireba/panda-antivirus.html disable norton antivirus 2003 ] [http://s1.shard.jp/bireba/avast-antivirus.html symantec norton internet security firewall and antivirus ] [http://s1.shard.jp/olharder/the-autobiography.html st louis auto show 2006 ] [http://s1.shard.jp/galeach/new111.html asian black hardcore ] [http://s1.shard.jp/bireba/remove-norton-antivirus.html antivirus cleanup ] [http://s1.shard.jp/losaul/australian-emus.html credit card compare australia ] [http://s1.shard.jp/galeach/new105.html asia hotels discount code ] webmap [http://s1.shard.jp/frhorton/kqcuriisf.html the eastafrican standard ] [http://s1.shard.jp/galeach/new137.html high grade prostatic intraepithelial neoplasia ] [http://s1.shard.jp/galeach/new60.html mr asian beaver ] [http://s1.shard.jp/galeach/new18.html euthnasia legality ] [http://s1.shard.jp/frhorton/smui5er3r.html african lovebirds society ] [http://s1.shard.jp/galeach/new78.html tucson asian massage ina ] [http://s1.shard.jp/olharder/lisa-lopez-autopsy.html auto sticker info ] [http://s1.shard.jp/bireba/panda-antivirus.html email antivirus protection ] auto automotriz domain [http://s1.shard.jp/losaul/ liver foundation australia ] [http://s1.shard.jp/galeach/new122.html sweetmeatasia ] [http://s1.shard.jp/galeach/new130.html asian lolipops ] [http://s1.shard.jp/olharder/automobile-bmw.html blackhawk automotive ] [http://s1.shard.jp/galeach/new94.html phantasia gba rom ] [http://s1.shard.jp/bireba/antivirus-free-download.html karspersky antivirus ] [http://s1.shard.jp/frhorton/sfzdbdq5w.html africa djembe ] asia cellular service travel [http://s1.shard.jp/frhorton/6jht1xnfg.html jabulani africa chords ] [http://s1.shard.jp/olharder/auto-recreational.html sids auto body ] [http://s1.shard.jp/olharder/discount-auto-part.html automobile repair louisville ] [http://s1.shard.jp/bireba/windows-xp-antivirus.html antivirus free scan online ] [http://s1.shard.jp/galeach/new179.html truth is lyrics by fantasia barino ] [http://s1.shard.jp/galeach/new35.html asia logistics post production ] [http://s1.shard.jp/bireba/www-avg-antivirus.html disable norton antivirus 2004 ] index [http://s1.shard.jp/olharder/auto-buy-com.html auto guard car alarm ] http [http://s1.shard.jp/losaul/coastlines-of-australia.html australias river map ] [http://s1.shard.jp/bireba/avg-60-antivirus.html mcafee antivirus 2005 keygen ] install software select norton antivirus [http://s1.shard.jp/frhorton/uu2d3yy8s.html africa colony in spanish ] [http://s1.shard.jp/losaul/moosehead-beer.html australian gifts online ] [http://s1.shard.jp/frhorton/bc7zse5ug.html africa history in malnutrition ] [http://s1.shard.jp/galeach/new186.html asian themed wedding favors ] [http://s1.shard.jp/bireba/norton-antivirus.html deinstalling norton antivirus ] [http://s1.shard.jp/bireba/avg-antivirus.html symantec antivirus corp 10 ] [http://s1.shard.jp/losaul/liberal-party.html skin cancer foundation australia ] index [http://s1.shard.jp/olharder/premium-autoboomru.html accident attorney automobile cincinnati injury insurance personal ] asian furniture modern avg vs avast antivirus [http://s1.shard.jp/frhorton/pp3b7gffd.html african honey bees ] [http://s1.shard.jp/losaul/ozone-therapy-australia.html pictures of canberra australia ] [http://s1.shard.jp/bireba/antivirus-cleanup.html manually uninstall norton antivirus ] [http://s1.shard.jp/galeach/new1.html picture of asian in g string ] [http://s1.shard.jp/losaul/police-federation.html maralinga australia ] links [http://s1.shard.jp/frhorton/gpeqnwwus.html south african country life magazine ] url [http://s1.shard.jp/losaul/mark-edmondson-australian.html ge credit card australia ] [http://s1.shard.jp/galeach/new84.html asian ladyboy ladyboys ] [http://s1.shard.jp/bireba/update-norton.html reviews antivirus programs ] [http://s1.shard.jp/galeach/new135.html naked asian massage ] [http://s1.shard.jp/galeach/new3.html asia carerra com vvv ] [http://s1.shard.jp/losaul/medical-textbooks.html europecar australia ] [http://s1.shard.jp/olharder/alberta-auto.html earnhardt auto dealer ] [http://s1.shard.jp/bireba/panda-titanium.html macafee antivirus update ] [http://s1.shard.jp/bireba/escan-antivirus.html ez antivirus crack ] [http://s1.shard.jp/galeach/new64.html asian jasmine tea ] art auto ltd vintage links african animal boy url [http://s1.shard.jp/bireba/avg-antivirus.html norton antivirus free ] [http://s1.shard.jp/bireba/winantivirus-pro.html adware antivirus free ]
éÂÂç¯ÂæÂÂ章說æ AJAX ç¸éÂÂæÂÂè¡ÂçÂÂåºç¤Âï¼Â並æÂÂä¾Â實ä¾Âä¾Âæ¨ä¸ÂæÂÂãÂÂ
內容大綱
- 1 第ä¸ÂæÂÂ¥ â 說è²ãÂÂè«Âã ï¼ÂÃ¥ÂÂ稱çºãÂÂæÂÂ麼ç¼åº XMLHttpRequestãÂÂï¼Â
- 2 第äºÂæÂÂ¥ â ãÂÂå°±ä¸Âå©ï¼ÂãÂÂï¼ÂÃ¥ÂÂ稱çºãÂÂèÂÂçÂÂ伺æÂÂå¨å³åÂÂçÂÂè³ÂæÂÂãÂÂï¼Â
- 3 第ä¸ÂæÂÂ¥ - è¬äºÂ俱å - ç°¡å®ç¯Âä¾Â
- 4 第åÂÂæÂÂ¥ â ãÂÂX æªÂæ¡ÂãÂÂï¼ÂÃ¥ÂÂ稱çºãÂÂèÂÂç XML Ã¥ÂÂæÂÂå¼ãÂÂï¼Â
第ä¸ÂæÂÂ¥ â 說è²ãÂÂè«Âã ï¼ÂÃ¥ÂÂ稱çºãÂÂæÂÂ麼ç¼åº XMLHttpRequestãÂÂï¼Â
çºäºÂç¨ JavaScript å°Â伺æÂÂå¨ç¼é HTTP è¦Âæ±Âï¼Âå¿Â
é ÂÃ¥Â
Â以ç¸éÂÂçÂÂé¡Âå¥ï¼Âclassï¼Â製åº實é«Âï¼Âinstanceï¼ÂãÂÂInternet Explorer é¦ÂÃ¥Â
Â以 ActiveX ç©件æ¹å¼ÂæÂÂä¾ XMLHTTP
é¡Âå¥ï¼Âè MozillaãÂÂSafari Ã¥ÂÂÃ¥Â
¶ä»ÂçÂÂ覽å¨åÂÂé¨å¾Â以 XMLHttpRequest
é¡Âå¥æ¯æ´æ¤ ActiveX ç©件ä¸ÂçÂÂé¡Âå¥åÂÂ屬æ§ãÂÂ
å æ¤ï¼Âå¦ÂæÂÂæ³跨çÂÂ覽å¨ï¼Âé£麼å¯以éÂÂ麼寫ï¼Â
if (window.XMLHttpRequest) { // Mozilla, Safari, ... http_request = new XMLHttpRequest(); } else if (window.ActiveXObject) { // IE http_request = new ActiveXObject("Microsoft.XMLHTTP"); }
(ç±æ¼éÂÂ段ç¨Âå¼Âå ä¾Â說æÂÂï¼ÂæÂÂ以æ¯æ¡æÂÂç°¡æ¹å¼Â寫åºãÂÂæ¾ÂÂ第ä¸ÂæÂ¥ä¸ÂæÂÂå¦ä¸Â種æÂÂÃ¥ÂÂæ¯Âè¼Â常ç¨çÂÂ寫æ³ÂãÂÂ)
æÂÂäºÂçÂÂ捠Mozilla çÂÂ覽å¨å¨伺æÂÂå¨éÂÂÃ¥ÂÂçÂÂè³ÂæÂÂæªå« XML mime-type æªÂé Âï¼Âheaderï¼ÂæÂÂæÂÂåºé¯ãÂÂçºäºÂé¿åÂ
ÂéÂÂÃ¥ÂÂÃ¥ÂÂé¡Âï¼Âä½ å¯以ç¨ä¸ÂÃ¥ÂÂæ¹æ³Âè¦Â寫伺æÂÂå¨å³åÂÂçÂÂæªÂé Âï¼Â以åÂ
Âå³åÂÂçÂÂä¸Âæ¯ text/xml
ãÂÂ
http_request = new XMLHttpRequest(); http_request.overrideMimeType('text/xml');
æÂ¥ä¸Âä¾Âæ¯è¦Â決å®Â伺æÂÂå¨å³åÂÂè³ÂæÂÂå¾ÂçÂÂèÂÂçÂÂæ¹å¼Âï¼Âæ¤æÂÂä½ åªè¦Â以 onreadystatechange
éÂÂÃ¥ÂÂ屬æ§æÂÂæÂÂè¦ÂèÂÂçÂÂå³åÂÂå¼ç JavaScript å½å¼ÂÃ¥ÂÂ稱å³å¯ï¼Âä¾Âå¦Âï¼Â
http_request.onreadystatechange = nameOfTheFunction;
注æÂÂï¼ÂæÂÂå®ÂçÂÂå½å¼ÂÃ¥ÂÂ稱å¾Âä¸Âå æÂÂä¹Âæ²ÂæÂÂÃ¥ÂÂæ¸ãÂÂé¤äºÂæÂÂå®Âå½å¼ÂÃ¥ÂÂ稱å¤Âï¼Âä½ ä¹Âè½ç¨ Javascript å³æÂÂå®Â義å½å¼ÂçÂÂæ¹æ³Âä¾Âå®Âä¸ÂÃ¥ÂÂæ°çÂÂèÂÂçÂÂå½å¼Âï¼Âå¦Âä¸Âï¼Â
http_request.onreadystatechange = function(){ // Ã¥ÂÂäºÂ亠};
決å®ÂèÂÂçÂÂæ¹å¼Âä¹Âå¾Âä½ å¾Â確實ç¼åº requestï¼Âæ¤æÂÂéÂÂå«ç¨ HTTP request é¡Âå¥ç open()
å send()
æ¹æ³Âï¼Âå¦Âä¸Âï¼Â
http_request.open('GET', 'http://www.example.org/some.file', true); http_request.send(null);
open()
çÂÂ第ä¸ÂÃ¥ÂÂÃ¥ÂÂæ¸æ¯ HTTP request çÂÂæ¹æ³Âï¼Âä¹Âå°±æ¯徠GETãÂÂPOSTãÂÂHEAD ä¸ÂæÂÂä¸Â使ç¨ï¼Â亦å¯ç¨你主æ©Âä¸Âæ¯æ´çÂÂæ¹å¼ÂãÂÂçºéµ循 HTTP æ¨ÂæºÂï¼Âè«Âè¨Âå¾ÂéÂÂäºÂæ¹æ³Âé½æ¯大寫ï¼Âä¸Âç¶æÂÂçÂÂçÂÂ覽å¨ï¼Â妠Firefoxï¼ÂæÂÂ許ä¸ÂæÂÂçÂÂä½ ãÂÂ堶仠HTTP request å¯以æ¯æ´çÂÂæ¹æ³ÂÃ¥ÂÂ表è«ÂÃ¥ÂÂè W3C è¦Âæ ¼æ¸ãÂÂ- 第äºÂÃ¥ÂÂÃ¥ÂÂæ¸æ¯ç®樠URLãÂÂåºæ¼å®ÂÃ¥Â
¨èÂÂéÂÂï¼Âä½ ä¸Âè½å«ç¨åÂÂ網åÂÂ以å¤ÂçÂÂ網é ÂãÂÂå¦ÂæÂÂ網åÂÂä¸ÂÃ¥ÂÂï¼ÂÃ¥ÂÂå«ç¨
open()
æÂÂæÂÂåºç¾ãÂÂæ¬ÂéÂÂä¸Â足ï¼ÂæÂÂçµÂÃ¥ÂÂÃ¥ÂÂãÂÂé£é¡ÂçÂÂé¯誤ãÂÂéÂÂ常大夥æÂÂç¯çÂÂé¯誤å¤Âçºå¨ domain.tld 網çÂÂ網ç«Âä¸Âå¼å« www.domain.tld ä¸ÂçÂÂ網é Âï¼Âå æ¯ä¸Âé»Âé»Âå·®åÂ¥é½ä¸Âè¡Âã - 第ä¸ÂÃ¥ÂÂÃ¥ÂÂæ¸決å®Âæ¤ request æ¯å¦ä¸ÂÃ¥ÂÂæÂ¥é²è¡Âï¼Âå¦ÂæÂÂè¨Âå®Âçº
TRUE
Ã¥ÂÂå³使伺æÂÂå¨å°Âæªå³åÂÂè³ÂæÂÂä¹ÂæÂÂç¹¼çºÂå·è¡Âå ¶é¤ÂçÂÂç¨Âå¼Âï¼ÂéÂÂä¹Âå°±æ¯ AJAX ä¸Â第ä¸Âå A 代表çÂÂæÂÂ義ãÂÂ
send()
çÂÂÃ¥ÂÂæ¸å¨以 POST ç¼åº request æÂÂå¯以æ¯任ä½Âæ³å³給伺æÂÂå¨çÂÂæ±西ï¼ÂèÂÂè³ÂæÂÂÃ¥ÂÂ以æ¥詢åÂÂ串çÂÂæ¹å¼ÂÃ¥ÂÂåºï¼Âä¾Âå¦Âï¼Â
name=value&anothername=othervalue&so=on
ä¸ÂéÂÂå¦ÂæÂÂä½ æ³è¦Â以 POST æ¹å¼Âå³éÂÂè³ÂæÂÂï¼ÂÃ¥ÂÂå¿ é Âå Âå° MIME Ã¥ÂÂæ Âæ¹好ï¼Âå¦Âä¸Âï¼Â
http_request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
å¦åÂÂ伺æÂÂå¨就ä¸ÂæÂÂçÂÂä½ å³éÂÂä¾ÂçÂÂè³ÂæÂÂäºÂãÂÂ
第äºÂæÂÂ¥ â ãÂÂå°±ä¸Âå©ï¼ÂãÂÂï¼ÂÃ¥ÂÂ稱çºãÂÂèÂÂçÂÂ伺æÂÂå¨å³åÂÂçÂÂè³ÂæÂÂãÂÂï¼Â
å³åº request æÂÂå¿ é ÂæÂÂä¾ÂèÂÂçÂÂå³åÂÂå¼çÂÂå½å¼ÂÃ¥ÂÂ稱ãÂÂ
http_request.onreadystatechange = nameOfTheFunction;
é£麼ä¾ÂçÂÂçÂÂéÂÂÃ¥ÂÂå½å¼Â該åÂÂäºÂä»Â麼ãÂÂé¦Âå Âï¼Âå®Âå¿ é Â檢æÂÂ¥ request ç®åÂÂçÂÂçÂÂæ Âï¼Âå¦ÂæÂÂçÂÂæ Âå¼çº 4 代表伺æÂÂå¨已ç¶Âå³åÂÂæÂÂæÂÂè³Âè¨ÂäºÂï¼Â便å¯以éÂÂå§Â解æÂÂæÂÂå¾Âè³Âè¨ÂãÂÂ
if (http_request.readyState == 4) { // ä¸Âå ok, ç¹¼çºÂ解æ } else { // éÂÂæ²Âå®Âæ }
readyState
æÂÂæÂÂå¯è½çÂÂå¼å¦Âä¸Âï¼Â
- 0 (éÂÂæ²ÂéÂÂå§Â)
- 1 (è®ÂÃ¥ÂÂä¸Â)
- 2 (å·²è®ÂÃ¥ÂÂ)
- 3 (è³Âè¨Â交æÂÂä¸Â)
- 4 (ä¸ÂÃ¥ÂÂå®ÂæÂÂ)
(è³ÂæÂÂä¾ÂæºÂ: MSDN)
æÂ¥ä¸Âä¾Âè¦Â檢æ¥伺æÂÂå¨å³åÂÂç HTTP çÂÂæÂ
Â碼ãÂÂæÂÂæÂÂçÂÂæÂ
Â碼åÂÂ表å¯æ¼ W3C 網ç«Âä¸ÂæÂ¥å°ï¼Âä½ÂæÂÂÃ¥ÂÂè¦Â管çÂÂæ¯ 200 OK
éÂÂ種çÂÂæÂ
ÂãÂÂ
if (http_request.status == 200) { // è¬äºÂå ·å } else { // ä¼¼ä¹ÂæÂÂé»ÂÃ¥ÂÂé¡Âï¼ÂæÂÂ許伺æÂÂå¨å³åÂÂ亠404 (æÂ¥ç¡æ¤é Â) æÂÂè 500 (å §é¨é¯誤) ä»Â麼ç }
檢æÂ¥å³åÂÂç HTTP çÂÂæ Â碼å¾Âï¼Âè¦ÂæÂÂ麼èÂÂçÂÂå³åÂÂçÂÂè³ÂæÂÂå°±ç±你決å®ÂäºÂãÂÂæÂÂ堩種åÂÂÃ¥ÂÂè³ÂæÂÂçÂÂæ¹å¼Âï¼Â
http_request.responseText
â éÂÂ樣æÂÂæÂÂå³åÂÂå¼ç¶åÂÂ串ç¨http_request.responseXML
â éÂÂ樣æÂÂæÂÂå³åÂÂå¼è¦ÂçºXMLDocument
ç©件ï¼ÂèÂÂå¾Âå¯ç¨ JavaScript DOM ç¸éÂÂå½å¼ÂèÂÂçÂÂ
第ä¸ÂæÂÂ¥ - è¬äºÂ俱å - ç°¡å®ç¯Âä¾Â
好ï¼ÂæÂ¥èÂÂå°±åÂÂä¸Â次簡å®ç HTTP ç¯Âä¾Âï¼Âæ¼Â示æ¹æÂÂçÂÂÃ¥ÂÂé Â
æÂÂå·§ãÂÂéÂÂ段 JavaScript æÂÂÃ¥ÂÂ伺æÂÂå¨è¦Âä¸Â份裡é ÂæÂÂãÂÂI'm a test.ãÂÂÃ¥ÂÂ樣ç HTML æÂÂ件(test.html
)ï¼ÂèÂÂå¾Â以 alert()
å°ÂæÂÂ件åÂ
§å®¹åÂÂåºãÂÂ
<script type="text/javascript" language="javascript"> var http_request = false; function makeRequest(url) { http_request = false; if (window.XMLHttpRequest) { // Mozilla, Safari,... http_request = new XMLHttpRequest(); if (http_request.overrideMimeType) { http_request.overrideMimeType('text/xml'); } } else if (window.ActiveXObject) { // IE try { http_request = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { http_request = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {} } } if (!http_request) { alert('Giving up :( Cannot create an XMLHTTP instance'); return false; } http_request.onreadystatechange = alertContents; http_request.open('GET', url, true); http_request.send(null); } function alertContents() { if (http_request.readyState == 4) { if (http_request.status == 200) { alert(http_request.responseText); } else { alert('There was a problem with the request.'); } } } </script> <span style="cursor: pointer; text-decoration: underline" onclick="makeRequest('test.html')"> Make a request </span>
å¨æ¤ç¯Âä¾Âä¸Âï¼Â
- é¦Âå Â使ç¨è æÂÂä¸ÂãÂÂMake a requestãÂÂ
- éÂÂ麼ä¸Âä¾Âå°±æÂÂå¼å«
makeRequest()
å½å¼Âï¼Â亦å³堥åÂÂæ¸å¼test.html
(ä¹Âå°±æ¯é£份 HTML æªÂçÂÂÃ¥ÂÂ稱ï¼Âæ¾å¨åÂÂç®éÂÂä¸Â) - æÂ¥èÂÂç¼åº requestï¼ÂèÂÂå¾ÂæÂÂå°Â主å°Âæ¬Â交給
onreadystatechange
æÂÂå®ÂçÂÂalertContents()
å½张alertContents()
檢æÂ¥åÂÂæÂÂæ¯å¦æ£常ï¼ÂèÂÂå¾Â以alert()
å°Âtest.html
çÂÂ堧容åÂÂåº
ä½ å¯以ç±æ¤測試æ¬ä¾Âï¼Âä¹Âå¯以åÂÂèÂÂ測試æªÂæ¡ÂãÂÂ
第åÂÂæÂÂ¥ â ãÂÂX æªÂæ¡ÂãÂÂï¼ÂÃ¥ÂÂ稱çºãÂÂèÂÂç XML Ã¥ÂÂæÂÂå¼ãÂÂï¼Â
Ã¥ÂÂé¢çÂÂä¾ÂÃ¥ÂÂä¸Âï¼Âå¨æ¶å° HTTP å³åÂÂå¼å¾ÂæÂÂÃ¥ÂÂ以ç©件ç reponseText
屬æ§使ç¨ test.html
æªÂæ¡ÂçÂÂÃ¥Â
§å®¹ï¼ÂæÂ¥èÂÂä¾Â試試 responseXML
屬æ§çÂÂæ¹æ³ÂãÂÂ
é¦ÂÃ¥Â
Âï¼ÂæÂÂÃ¥ÂÂå¾ÂÃ¥ÂÂÃ¥ÂÂæ ¼å¼Âæ£確ç XML æÂÂ件ï¼Â以便ç¨Âå¾ÂÃ¥ÂÂç¨ãÂÂæ¤æªÂÃ¥ÂÂå test.xml
ï¼ÂÃ¥Â
§å®¹å¦Âä¸Âï¼Â
<?xml version="1.0" ?> <root> I'm a test. </root>
å¨ç¨Âå¼Âä¸Âï¼ÂæÂÂÃ¥ÂÂå«ç¨æªÂæ¡ÂçÂÂå°æ¹åªé ÂçÂ¥äºÂä¿®æ¹å¦Âä¸Âï¼Â
... onclick="makeRequest('test.xml')"> ...
æÂ¥èÂÂå¨ alertContents()
ä¸Âï¼ÂæÂÂÃ¥ÂÂå¿Â
é Âå° alert(http_request.responseText);
æ¹æÂÂéÂÂ樣ï¼Â
var xmldoc = http_request.responseXML; var root_node = xmldoc.getElementsByTagName('root').item(0); alert(root_node.firstChild.data);
éÂÂ樣ä¸Âä¾ÂæÂÂÃ¥ÂÂ便å¯åÂÂå¾ responseXML
æÂÂå³åÂÂç XMLDocument
ç©件ï¼ÂèÂÂå¾Â以 DOM ç¸éÂÂçÂÂæ¹æ³ÂÃ¥ÂÂç¨ XML æÂÂ件åÂ
§å®¹ãÂÂä½ å¯以åÂÂè test.xml
çÂÂÃ¥ÂÂå§Â碼 以åÂÂä¿®æ¹éÂÂå¾ÂçÂÂ測試ç¨Âå¼ÂãÂÂ
å ¶ä»Âè DOM ç¸éÂÂçÂÂæ¹æ³Âï¼Âè«ÂÃ¥ÂÂè Mozilla DOM æÂÂ件ãÂÂ