锘??xml version="1.0" encoding="utf-8" standalone="yes"?>亚洲精品综合一二三区在线 ,亚洲av日韩精品久久久久久a,亚洲精品视频免费看http://www.tkk7.com/paulwong/category/10812.htmlzh-cnWed, 28 Feb 2007 21:11:48 GMTWed, 28 Feb 2007 21:11:48 GMT60AJAX 涓婃墜綃?/title><link>http://www.tkk7.com/paulwong/articles/44684.html</link><dc:creator>paulwong</dc:creator><author>paulwong</author><pubDate>Fri, 05 May 2006 14:21:00 GMT</pubDate><guid>http://www.tkk7.com/paulwong/articles/44684.html</guid><wfw:comment>http://www.tkk7.com/paulwong/comments/44684.html</wfw:comment><comments>http://www.tkk7.com/paulwong/articles/44684.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.tkk7.com/paulwong/comments/commentRss/44684.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/paulwong/services/trackbacks/44684.html</trackback:ping><description><![CDATA[ <h1>AJAX 涓婃墜綃?o:p></o:p></h1> <o:p> </o:p> <h2>絎竴姝?鈥?璇村0銆岃銆?錛堝張縐頒負銆屾庝箞鍙戝嚭 XMLHttpRequest銆嶏級 <o:p></o:p></h2> <p>涓轟簡鐢?JavaScript 瀵規湇鍔″櫒鍙戦?HTTP 瑕佹眰錛屼綘蹇呴』鍏堜互鐩稿叧鐨勭被鍒紙class錛夊埗鍑哄疄浣擄紙instance錛夈侷nternet<br />Explorer 棣栧厛浠?ActiveX 瀵硅薄鏂瑰紡鎻愪緵 <code>XMLHTTP</code> 綾誨埆錛岃?Mozilla銆丼afari鍙婂叾瀹冩祻瑙堝櫒鍒欓殢鍚庝互 <code>XMLHttpRequest</code> 綾誨埆鏀寔姝?ActiveX 瀵硅薄涓殑綾誨埆鍙婂睘鎬с?<o:p></o:p></p> <br /> <p>鍥犳錛屽鏋滄兂璺ㄦ祻瑙堝櫒錛岄偅涔堝彲浠ヨ繖涔堝啓錛毬?/p> <p> <br /> <o:p> </o:p> </p> <div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"> <!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--> <span style="color: rgb(0, 0, 255);">if</span> <span style="color: rgb(0, 0, 0);">聽(window.XMLHttpRequest)聽{聽</span> <span style="color: rgb(0, 128, 0);">//</span> <span style="color: rgb(0, 128, 0);">聽Mozilla,聽Safari,聽<img src="http://www.tkk7.com/images/dot.gif" /></span> <span style="color: rgb(0, 128, 0);"> <br /> </span> <span style="color: rgb(0, 0, 0);"> <br />聽聽聽聽http_request聽</span> <span style="color: rgb(0, 0, 0);">=</span> <span style="color: rgb(0, 0, 0);">聽</span> <span style="color: rgb(0, 0, 255);">new</span> <span style="color: rgb(0, 0, 0);">聽XMLHttpRequest();<br /><br />}聽</span> <span style="color: rgb(0, 0, 255);">else</span> <span style="color: rgb(0, 0, 0);">聽</span> <span style="color: rgb(0, 0, 255);">if</span> <span style="color: rgb(0, 0, 0);">聽(window.ActiveXObject)聽{聽</span> <span style="color: rgb(0, 128, 0);">//</span> <span style="color: rgb(0, 128, 0);">聽IE</span> <span style="color: rgb(0, 128, 0);"> <br /> </span> <span style="color: rgb(0, 0, 0);"> <br />聽聽聽聽http_request聽</span> <span style="color: rgb(0, 0, 0);">=</span> <span style="color: rgb(0, 0, 0);">聽</span> <span style="color: rgb(0, 0, 255);">new</span> <span style="color: rgb(0, 0, 0);">聽ActiveXObject(</span> <span style="color: rgb(0, 0, 0);">"</span> <span style="color: rgb(0, 0, 0);">Microsoft.XMLHTTP</span> <span style="color: rgb(0, 0, 0);">"</span> <span style="color: rgb(0, 0, 0);">);<br /><br />}<br /><br /></span> </div> <o:p> </o:p> <p> <br /> </p> <p>(鐢變簬榪欐紼嬪簭浠呬緵璇存槑錛屾墍浠ユ槸閲囨渶綆鏂瑰紡鍐欏嚭銆傛湰鏂囩涓夋涓湁鍙︿竴縐嶆垜浠瘮杈冨父鐢ㄧ殑鍐欐硶銆? <o:p></o:p></p> <p>鏈変簺鐗堟湰鐨?Mozilla 嫻忚鍣ㄥ湪鏈嶅姟鍣ㄩ佸洖鐨勬暟鎹湭鍚?XML mime-type 鏂囦歡澶達紙header錛夋椂浼氬嚭閿欍備負浜嗛伩鍏嶈繖涓棶棰橈紝浣犲彲浠ョ敤涓嬪垪鏂規硶瑕嗗啓鏈嶅姟鍣ㄤ紶鍥炵殑妗eご錛屼互鍏嶄紶鍥炵殑涓嶆槸<code>text/xml</code>銆?/p> <p> <br /> <o:p> </o:p> </p> <div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"> <!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--> <span style="color: rgb(0, 0, 0);">http_request聽</span> <span style="color: rgb(0, 0, 0);">=</span> <span style="color: rgb(0, 0, 0);">聽</span> <span style="color: rgb(0, 0, 255);">new</span> <span style="color: rgb(0, 0, 0);">聽XMLHttpRequest();<br /><br />http_request.overrideMimeType('text</span> <span style="color: rgb(0, 0, 0);">/</span> <span style="color: rgb(0, 0, 0);">xml');</span> </div> <o:p> </o:p> <p> <br /> </p> <p>鎺ヤ笅鏉ユ槸瑕佸喅瀹氭湇鍔″櫒浼犲洖璧勬枡鍚庣殑澶勭悊鏂瑰紡錛屾鏃朵綘鍙浠?<code>onreadystatechange</code> 榪欎釜灞炴ф寚鏄庤澶勭悊浼犲洖鍊肩殑<br />JavaScript 鍑藉紡鍚嶇О鍗沖彲錛屼緥濡傦細</p> <p> <br /> <o:p> </o:p> </p> <p> <code> </code> </p> <div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"> <!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--> <span style="color: rgb(0, 0, 0);">http_request.onreadystatechange聽</span> <span style="color: rgb(0, 0, 0);">=</span> <span style="color: rgb(0, 0, 0);">聽nameOfTheFunction;</span> </div> <br /> <o:p> </o:p> <p> </p> <p>娉ㄦ剰錛屾寚瀹氱殑鍑藉紡鍚嶇О鍚庝笉鍔犳嫭鍙蜂篃娌℃湁鍙傛暟銆傞櫎浜嗘寚瀹氬嚱寮忓悕縐板錛屼綘涔熻兘鐢?Javascript 瀹炴椂瀹氫箟鍑藉紡鐨勬柟娉曟潵瀹氫竴涓柊鐨勫鐞嗗嚱寮忥紝濡備笅錛?/p> <p> <br /> <o:p> </o:p> </p> <div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"> <!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--> <span style="color: rgb(0, 0, 0);">http_request.onreadystatechange聽</span> <span style="color: rgb(0, 0, 0);">=</span> <span style="color: rgb(0, 0, 0);">聽</span> <span style="color: rgb(0, 0, 255);">function</span> <span style="color: rgb(0, 0, 0);">(){<br /><br />聽聽聽聽</span> <span style="color: rgb(0, 128, 0);">//</span> <span style="color: rgb(0, 128, 0);">聽鍋氫簺浜?/span> <span style="color: rgb(0, 128, 0);"> <br /> </span> <span style="color: rgb(0, 0, 0);"> <br />};</span> </div> <o:p> </o:p> <p> <br /> </p> <p>鍐沖畾澶勭悊鏂瑰紡涔嬪悗浣犲緱紜疄鍙戝嚭 request錛屾鏃墮渶鍙敤 HTTP request 綾誨埆鐨?<code>open()</code> 鍙?<code>send()</code> 鏂規硶錛屽涓嬶細</p> <p> <br /> <o:p> </o:p> </p> <div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"> <!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--> <span style="color: rgb(0, 0, 0);">http_request.open('GET',聽'http:</span> <span style="color: rgb(0, 128, 0);">//</span> <span style="color: rgb(0, 128, 0);">www.example.org/some.file',聽true);</span> <span style="color: rgb(0, 128, 0);"> <br /> </span> <span style="color: rgb(0, 0, 0);">http_request.send(</span> <span style="color: rgb(0, 0, 255);">null</span> <span style="color: rgb(0, 0, 0);">);<br /><br /></span> </div> <o:p> </o:p> <ul type="disc"> <li id="pz3vnp3" class="MsoNormal"> <code>open()</code> 鐨勭涓涓弬鏁版槸<br />聽聽聽聽 HTTP request 鐨勬柟娉曪紝涔熷氨鏄粠<br />聽聽聽聽 GET銆丳OST銆丠EAD 涓嫨涓浣跨敤錛屼害鍙敤浣犱富鏈轟笂鏀寔鐨勬柟寮忋備負閬靛驚 HTTP 鏍囧噯錛岃璁板緱榪欎簺鏂規硶閮芥槸澶у啓錛屼笉鐒舵湁鐨勬祻瑙堝櫒錛堝 Firefox錛夋垨璁鎬笉浼氱悊浣犮傚叾瀹?HTTP request 鍙互鏀寔鐨勬柟娉曞垪琛ㄨ鍙傝?br />聽聽聽聽 <a target="_blank">W3C 瑙勬牸涔?/a> (<i><a target="_blank" >http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html</a></i>)銆?<o:p></o:p></li> <li id="dxdj3bd" class="MsoNormal">絎簩涓弬鏁版槸鐩爣 URL銆傚熀浜庡畨鍏ㄨ冭檻錛屼綘涓嶈兘鍙敤鍚岀綉鍩熶互澶栫殑緗戦〉銆傚鏋滅綉鍩熶笉鍚岋紝鍒欏彨鐢?br />聽聽聽聽 <code>open()</code> 鏃朵細鍑虹幇銆屾潈闄愪笉瓚籌紝鎷掔粷瀛樺彇銆嶉偅綾葷殑閿欒銆傞氬父澶т紮浼氱姱鐨勯敊璇涓哄湪 domain.tld 緗戠殑緗戠珯涓嬪懠鍙?<a target="_blank" >www.domain.tld</a> 涓殑緗戦〉錛屼粎鏄竴鐐圭偣宸埆閮戒笉琛屻?br />聽聽聽聽 <o:p></o:p></li> <li id="ld3h3h3" class="MsoNormal">絎笁涓弬鏁板喅瀹氭 request 鏄惁涓嶅悓姝ヨ繘琛岋紝濡傛灉璁懼畾涓?br />聽聽聽聽 <code>TRUE</code> 鍒欏嵆浣挎湇鍔″櫒灝氭湭浼犲洖鏁版嵁涔熶細緇х畫鎵ц鍏朵綑鐨勭▼搴忥紝榪欎篃灝辨槸 AJAX 涓涓涓?A 浠h〃鐨勬剰涔夈?<o:p></o:p></li> </ul> <p> <code>send()</code> 鐨勫弬鏁板湪浠?POST 鍙戝嚭 request 鏃跺彲浠ユ槸浠諱綍鎯充紶緇欐湇鍔″櫒鐨勪笢瑗匡紝鑰屾暟鎹垯浠ユ煡璇㈠瓧絎︿覆鐨勬柟寮忓垪鍑猴紝渚嬪錛?<o:p></o:p></p> <p> <code> </code>聽</p> <div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"> <!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--> <span style="color: rgb(0, 0, 0);">name</span> <span style="color: rgb(0, 0, 0);">=</span> <span style="color: rgb(0, 0, 0);">value</span> <span style="color: rgb(0, 0, 0);">&</span> <span style="color: rgb(0, 0, 0);">anothername</span> <span style="color: rgb(0, 0, 0);">=</span> <span style="color: rgb(0, 0, 0);">othervalue</span> <span style="color: rgb(0, 0, 0);">&</span> <span style="color: rgb(0, 0, 0);">so</span> <span style="color: rgb(0, 0, 0);">=</span> <span style="color: rgb(0, 0, 0);">on</span> </div> <o:p> </o:p> <p>涓嶈繃濡傛灉浣犳兂瑕佷互 POST 鏂瑰紡浼犻佹暟鎹紝鍒欏繀欏誨厛灝?MIME 鍨嬫佹敼濂斤紝濡備笅錛?<o:p></o:p></p> <pre> <div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"> <!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--> <span style="color: rgb(0, 0, 0);">http_request.setRequestHeader('Content</span> <span style="color: rgb(0, 0, 0);">-</span> <span style="color: rgb(0, 0, 0);">Type',聽'application</span> <span style="color: rgb(0, 0, 0);">/</span> <span style="color: rgb(0, 0, 0);">x</span> <span style="color: rgb(0, 0, 0);">-</span> <span style="color: rgb(0, 0, 0);">www</span> <span style="color: rgb(0, 0, 0);">-</span> <span style="color: rgb(0, 0, 0);">form</span> <span style="color: rgb(0, 0, 0);">-</span> <span style="color: rgb(0, 0, 0);">urlencoded');<br /><br /></span> </div> <br /> <o:p> </o:p> </pre> <p>鍚﹀垯鏈嶅姟鍣ㄥ氨涓嶄細鐞嗕綘浼犺繃鏉ョ殑鏁版嵁浜嗐?<o:p></o:p></p> <h2>絎簩姝?鈥?銆屽氨涓婂挬錛併嶏紙鍙堢О涓恒屽鐞嗘湇鍔″櫒浼犲洖鐨勬暟鎹嶏級 <o:p></o:p></h2> <p>浼犲嚭 request 鏃跺繀欏繪彁渚涘鐞嗕紶鍥炲肩殑鍑藉紡鍚嶇О銆?<o:p></o:p></p> <p> <code> </code> </p> <div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"> <!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--> <span style="color: rgb(0, 0, 0);">http_request.onreadystatechange聽</span> <span style="color: rgb(0, 0, 0);">=</span> <span style="color: rgb(0, 0, 0);">聽nameOfTheFunction;</span> </div> <br /> <o:p> </o:p> <p> </p> <pre>////////////////////////////////////////////////////////////////////<o:p></o:p></pre> <pre>//浣嗘槸錛孎ireFox 瀵筼nreadyStateChange娌℃湁鍙嶅簲錛屾庝箞鍔烇紝榪欎釜鏂規硶涓嶈兘鐢ㄥ湪<o:p></o:p></pre> <pre>//FireFox 涓紝鏈夋病鏈夊叾瀹冪殑鏂規硶錛?o:p></o:p></pre> <pre>//聽聽聽聽聽聽Added by <a target="_blank" >www.besook.com</a> 2006-03-19<o:p></o:p></pre> <pre>//////////////////////////////////////////////////////////////<o:p></o:p></pre> <p>閭d箞鏉ョ湅鐪嬭繖涓嚱寮忚鍋氫簺浠涔堛傞鍏堬紝瀹冨繀欏繪鏌?request 鐩墠鐨勭姸鎬侊細濡傛灉鐘舵佸間負 4 浠h〃鏈嶅姟鍣ㄥ凡緇忎紶鍥炴墍鏈変俊鎭簡錛屼究鍙互寮濮嬭В鏋愭墍寰椾俊鎭?/p> <p> <br /> <o:p> </o:p> </p> <div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"> <!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--> <span style="color: rgb(0, 0, 255);">if</span> <span style="color: rgb(0, 0, 0);">聽(http_request.readyState聽</span> <span style="color: rgb(0, 0, 0);">==</span> <span style="color: rgb(0, 0, 0);">聽</span> <span style="color: rgb(0, 0, 0);">4</span> <span style="color: rgb(0, 0, 0);">)聽{<br /><br />聽聽聽聽</span> <span style="color: rgb(0, 128, 0);">//</span> <span style="color: rgb(0, 128, 0);">聽涓鍒嚶爋k,聽緇х畫瑙f瀽</span> <span style="color: rgb(0, 128, 0);"> <br /> </span> <span style="color: rgb(0, 0, 0);"> <br />}聽</span> <span style="color: rgb(0, 0, 255);">else</span> <span style="color: rgb(0, 0, 0);">聽{<br /><br />聽聽聽聽</span> <span style="color: rgb(0, 128, 0);">//</span> <span style="color: rgb(0, 128, 0);">聽榪樻病瀹屾垚</span> <span style="color: rgb(0, 128, 0);"> <br /> </span> <span style="color: rgb(0, 0, 0);"> <br />}</span> </div> <o:p> </o:p> <p> <code> <br /> </code> </p> <p> <code>readyState</code> 鎵鏈夊彲鑳界殑鍊煎涓嬶細 <o:p></o:p></p> <ul type="disc"> <li id="33brnpt" class="MsoNormal">0 (榪樻病寮濮? <o:p></o:p></li> <li id="113b33j" class="MsoNormal">1 (璇誨彇涓? <o:p></o:p></li> <li id="hf9bxzz" class="MsoNormal">2 (宸茶鍙? <o:p></o:p></li> <li id="l99xh39" class="MsoNormal">3 (淇℃伅浜ゆ崲涓? <o:p></o:p></li> <li id="tftfrtr" class="MsoNormal">4 (涓鍒囧畬鎴? <o:p></o:p></li> </ul> <p>(<a target="_blank">璧勬枡鏉ユ簮: MSDN</a> (<i><a target="_blank" >http://msdn.microsoft.com/workshop/author/dhtml/reference/properties/readystate_1.asp</a></i>))<br /><o:p></o:p></p> <p>鎺ヤ笅鏉ヨ媯鏌ユ湇鍔″櫒浼犲洖鐨?HTTP 鐘舵佺爜銆傛墍鏈夌姸鎬佺爜鍒楄〃鍙簬 <a target="_blank">W3C<br />緗戠珯</a> (<i><a target="_blank" >http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html</a></i>)涓婃煡鍒幫紝浣嗘垜浠綆$殑鏄?code>200 OK</code> 榪欑鐘舵併?/p> <p> <br /> <o:p> </o:p> </p> <div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"> <!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--> <span style="color: rgb(0, 0, 255);">if</span> <span style="color: rgb(0, 0, 0);">聽(http_request.status聽</span> <span style="color: rgb(0, 0, 0);">==</span> <span style="color: rgb(0, 0, 0);">聽</span> <span style="color: rgb(0, 0, 0);">200</span> <span style="color: rgb(0, 0, 0);">)聽{<br /><br />聽聽聽聽</span> <span style="color: rgb(0, 128, 0);">//</span> <span style="color: rgb(0, 128, 0);">聽涓囦簨鍏峰</span> <span style="color: rgb(0, 128, 0);"> <br /> </span> <span style="color: rgb(0, 0, 0);"> <br />}聽</span> <span style="color: rgb(0, 0, 255);">else</span> <span style="color: rgb(0, 0, 0);">聽{<br /><br />聽聽聽聽</span> <span style="color: rgb(0, 128, 0);">//</span> <span style="color: rgb(0, 128, 0);">聽浼間箮鏈夌偣闂錛屾垨璁告湇鍔″櫒浼犲洖浜喡?04聽(鏌ユ棤姝ら〉)聽鎴栬吢?00聽(鍐呴儴閿欒)聽浠涔堢殑</span> <span style="color: rgb(0, 128, 0);"> <br /> </span> <span style="color: rgb(0, 0, 0);"> <br />}</span> </div> <o:p> </o:p> <p> <br /> </p> <p> <br /> </p> <p>媯鏌ヤ紶鍥炵殑 HTTP 鐘舵佺爜鍚庯紝瑕佹庝箞澶勭悊浼犲洖鐨勬暟鎹氨鐢變綘鍐沖畾浜嗐傛湁涓ょ瀛樺彇鏁版嵁鐨勬柟寮忥細 <o:p></o:p></p> <ul type="disc"> <li id="3199ld9" class="MsoNormal"> <code>http_request.responseText</code> 鈥?榪欐牱浼氭妸浼犲洖鍊煎綋瀛楃涓茬敤<br />聽聽聽聽 <o:p></o:p></li> <li id="n3f99hr" class="MsoNormal"> <code>http_request.responseXML</code> 鈥?榪欐牱浼氭妸浼犲洖鍊艱涓?br />聽聽聽聽 <code>XMLDocument</code> 瀵硅薄錛岃屽悗鍙敤<br />聽聽聽聽 JavaScript DOM 鐩稿叧鍑藉紡澶勭悊 <o:p></o:p></li> </ul> <h2>絎笁姝?- 涓囦簨淇卞 - 綆鍗曡寖渚?<o:p></o:p></h2> <p>濂斤紝鎺ョ潃灝卞仛涓嬈$畝鍗曠殑 HTTP 鑼冧緥錛屾紨紺烘柟鎵嶇殑鍚勯」鎶宸с傝繖孌?JavaScript 浼氬悜鏈嶅姟鍣ㄨ涓浠介噷澶存湁銆孖'm<br />a test.銆嶅瓧鏍風殑 HTML 鏂囦歡(<code>test.html</code>)錛岃屽悗浠?<code>alert()</code> 灝嗘枃浠跺唴瀹瑰垪鍑恒?/p> <p> <br /> <o:p> </o:p> </p> <div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"> <!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--> <span style="color: rgb(0, 0, 0);"><</span> <span style="color: rgb(0, 0, 0);">script聽type</span> <span style="color: rgb(0, 0, 0);">=</span> <span style="color: rgb(0, 0, 0);">"</span> <span style="color: rgb(0, 0, 0);">text/javascript</span> <span style="color: rgb(0, 0, 0);">"</span> <span style="color: rgb(0, 0, 0);">聽language</span> <span style="color: rgb(0, 0, 0);">=</span> <span style="color: rgb(0, 0, 0);">"</span> <span style="color: rgb(0, 0, 0);">javascript</span> <span style="color: rgb(0, 0, 0);">"</span> <span style="color: rgb(0, 0, 0);">></span> <span style="color: rgb(0, 0, 0);"> <br /> <br />聽聽聽聽</span> <span style="color: rgb(0, 0, 255);">var</span> <span style="color: rgb(0, 0, 0);">聽http_request聽</span> <span style="color: rgb(0, 0, 0);">=</span> <span style="color: rgb(0, 0, 0);">聽</span> <span style="color: rgb(0, 0, 255);">false</span> <span style="color: rgb(0, 0, 0);">;<br /><br />聽聽聽聽</span> <span style="color: rgb(0, 0, 255);">function</span> <span style="color: rgb(0, 0, 0);">聽makeRequest(url)聽{<br /><br />聽聽聽聽聽聽聽聽http_request聽</span> <span style="color: rgb(0, 0, 0);">=</span> <span style="color: rgb(0, 0, 0);">聽</span> <span style="color: rgb(0, 0, 255);">false</span> <span style="color: rgb(0, 0, 0);">;<br /><br />聽聽聽聽聽聽聽聽</span> <span style="color: rgb(0, 0, 255);">if</span> <span style="color: rgb(0, 0, 0);">聽(window.XMLHttpRequest)聽{聽</span> <span style="color: rgb(0, 128, 0);">//</span> <span style="color: rgb(0, 128, 0);">聽Mozilla,聽Safari,<img src="http://www.tkk7.com/images/dot.gif" /></span> <span style="color: rgb(0, 128, 0);"> <br /> </span> <span style="color: rgb(0, 0, 0);"> <br />聽聽聽聽聽聽聽聽聽聽聽聽http_request聽</span> <span style="color: rgb(0, 0, 0);">=</span> <span style="color: rgb(0, 0, 0);">聽</span> <span style="color: rgb(0, 0, 255);">new</span> <span style="color: rgb(0, 0, 0);">聽XMLHttpRequest();<br /><br />聽聽聽聽聽聽聽聽聽聽聽聽</span> <span style="color: rgb(0, 0, 255);">if</span> <span style="color: rgb(0, 0, 0);">聽(http_request.overrideMimeType)聽{<br /><br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽http_request.overrideMimeType('text</span> <span style="color: rgb(0, 0, 0);">/</span> <span style="color: rgb(0, 0, 0);">xml');<br /><br />聽聽聽聽聽聽聽聽聽聽聽聽}<br /><br />聽聽聽聽聽聽聽聽}聽</span> <span style="color: rgb(0, 0, 255);">else</span> <span style="color: rgb(0, 0, 0);">聽</span> <span style="color: rgb(0, 0, 255);">if</span> <span style="color: rgb(0, 0, 0);">聽(window.ActiveXObject)聽{聽</span> <span style="color: rgb(0, 128, 0);">//</span> <span style="color: rgb(0, 128, 0);">聽IE</span> <span style="color: rgb(0, 128, 0);"> <br /> </span> <span style="color: rgb(0, 0, 0);"> <br />聽聽聽聽聽聽聽聽聽聽聽聽</span> <span style="color: rgb(0, 0, 255);">try</span> <span style="color: rgb(0, 0, 0);">聽{<br /><br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽http_request聽</span> <span style="color: rgb(0, 0, 0);">=</span> <span style="color: rgb(0, 0, 0);">聽</span> <span style="color: rgb(0, 0, 255);">new</span> <span style="color: rgb(0, 0, 0);">聽ActiveXObject(</span> <span style="color: rgb(0, 0, 0);">"</span> <span style="color: rgb(0, 0, 0);">Msxml2.XMLHTTP</span> <span style="color: rgb(0, 0, 0);">"</span> <span style="color: rgb(0, 0, 0);">);<br /><br />聽聽聽聽聽聽聽聽聽聽聽聽}聽</span> <span style="color: rgb(0, 0, 255);">catch</span> <span style="color: rgb(0, 0, 0);">聽(e)聽{<br /><br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽</span> <span style="color: rgb(0, 0, 255);">try</span> <span style="color: rgb(0, 0, 0);">聽{<br /><br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽http_request聽</span> <span style="color: rgb(0, 0, 0);">=</span> <span style="color: rgb(0, 0, 0);">聽</span> <span style="color: rgb(0, 0, 255);">new</span> <span style="color: rgb(0, 0, 0);">聽ActiveXObject(</span> <span style="color: rgb(0, 0, 0);">"</span> <span style="color: rgb(0, 0, 0);">Microsoft.XMLHTTP</span> <span style="color: rgb(0, 0, 0);">"</span> <span style="color: rgb(0, 0, 0);">);<br /><br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽}聽</span> <span style="color: rgb(0, 0, 255);">catch</span> <span style="color: rgb(0, 0, 0);">聽(e)聽{}<br /><br />聽聽聽聽聽聽聽聽聽聽聽聽}<br /><br />聽聽聽聽聽聽聽聽}<br /><br />聽聽聽聽聽聽聽聽</span> <span style="color: rgb(0, 0, 255);">if</span> <span style="color: rgb(0, 0, 0);">聽(</span> <span style="color: rgb(0, 0, 0);">!</span> <span style="color: rgb(0, 0, 0);">http_request)聽{<br /><br />聽聽聽聽聽聽聽聽聽聽聽聽alert('Giving聽up聽:(聽Cannot聽create聽an聽XMLHTTP聽instance');<br /><br />聽聽聽聽聽聽聽聽聽聽聽聽</span> <span style="color: rgb(0, 0, 255);">return</span> <span style="color: rgb(0, 0, 0);">聽</span> <span style="color: rgb(0, 0, 255);">false</span> <span style="color: rgb(0, 0, 0);">;<br /><br />聽聽聽聽聽聽聽聽}<br /><br />聽聽聽聽聽聽聽聽http_request.onreadystatechange聽</span> <span style="color: rgb(0, 0, 0);">=</span> <span style="color: rgb(0, 0, 0);">聽alertContents;<br /><br />聽聽聽聽聽聽聽聽http_request.open('GET',聽url,聽</span> <span style="color: rgb(0, 0, 255);">true</span> <span style="color: rgb(0, 0, 0);">);<br /><br />聽聽聽聽聽聽聽聽http_request.send(</span> <span style="color: rgb(0, 0, 255);">null</span> <span style="color: rgb(0, 0, 0);">);<br /><br />聽聽聽聽}<br /><br />聽聽聽聽</span> <span style="color: rgb(0, 0, 255);">function</span> <span style="color: rgb(0, 0, 0);">聽alertContents()聽{<br /><br />聽聽聽聽聽聽聽聽</span> <span style="color: rgb(0, 0, 255);">if</span> <span style="color: rgb(0, 0, 0);">聽(http_request.readyState聽</span> <span style="color: rgb(0, 0, 0);">==</span> <span style="color: rgb(0, 0, 0);">聽</span> <span style="color: rgb(0, 0, 0);">4</span> <span style="color: rgb(0, 0, 0);">)聽{<br /><br />聽聽聽聽聽聽聽聽聽聽聽聽</span> <span style="color: rgb(0, 0, 255);">if</span> <span style="color: rgb(0, 0, 0);">聽(http_request.status聽</span> <span style="color: rgb(0, 0, 0);">==</span> <span style="color: rgb(0, 0, 0);">聽</span> <span style="color: rgb(0, 0, 0);">200</span> <span style="color: rgb(0, 0, 0);">)聽{<br /><br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽alert(http_request.responseText);<br /><br />聽聽聽聽聽聽聽聽聽聽聽聽}聽</span> <span style="color: rgb(0, 0, 255);">else</span> <span style="color: rgb(0, 0, 0);">聽{<br /><br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽alert('There聽was聽a聽problem聽</span> <span style="color: rgb(0, 0, 255);">with</span> <span style="color: rgb(0, 0, 0);">聽the聽request.');<br /><br />聽聽聽聽聽聽聽聽聽聽聽聽}<br /><br />聽聽聽聽聽聽聽聽}<br /><br />聽聽聽聽}<br /><br /></span> <span style="color: rgb(0, 0, 0);"></</span> <span style="color: rgb(0, 0, 0);">script</span> <span style="color: rgb(0, 0, 0);">></span> <span style="color: rgb(0, 0, 0);"> <br /> <br /> </span> <span style="color: rgb(0, 0, 0);"><</span> <span style="color: rgb(0, 0, 0);">span<br /><br />聽聽聽聽style</span> <span style="color: rgb(0, 0, 0);">=</span> <span style="color: rgb(0, 0, 0);">"</span> <span style="color: rgb(0, 0, 0);">cursor:聽pointer;聽text-decoration:聽underline</span> <span style="color: rgb(0, 0, 0);">"</span> <span style="color: rgb(0, 0, 0);"> <br /> <br />聽聽聽聽onclick</span> <span style="color: rgb(0, 0, 0);">=</span> <span style="color: rgb(0, 0, 0);">"</span> <span style="color: rgb(0, 0, 0);">makeRequest('test.html')</span> <span style="color: rgb(0, 0, 0);">"</span> <span style="color: rgb(0, 0, 0);">></span> <span style="color: rgb(0, 0, 0);"> <br /> <br />聽聽聽聽聽聽聽聽Make聽a聽request<br /><br /></span> <span style="color: rgb(0, 0, 0);"></</span> <span style="color: rgb(0, 0, 0);">span</span> <span style="color: rgb(0, 0, 0);">></span> </div> <o:p> </o:p> <p> <br /> </p> <p>鍦ㄦ鑼冧緥涓細 <o:p></o:p></p> <ul type="disc"> <li id="j3nlpx3" class="MsoNormal">棣栧厛浣跨敤鑰呮寜涓嬨孧ake a request銆?<o:p></o:p></li> <li id="3rvv99j" class="MsoNormal">榪欎箞涓鏉ュ氨浼氬懠鍙?br />聽聽聽聽 <code>makeRequest()</code> 鍑藉紡錛屼害浼犲叆鍙傛暟鍊?<code>test.html</code> (涔熷氨鏄偅浠?HTML 妗g殑鍚嶇О錛屾斁鍦ㄥ悓鐩綍涓? <o:p></o:p></li> <li id="3vrrv93" class="MsoNormal">鎺ョ潃鍙戝嚭 request錛岃屽悗浼氬皢涓誨鏉冧氦緇?br />聽聽聽聽 <code>onreadystatechange</code> 鎸囧畾鐨?<code>alertContents()</code> 鍑藉紡 <o:p></o:p></li> <li id="tld39vl" class="MsoNormal"> <code>alertContents()</code> 媯鏌ュ搷搴旀槸鍚︽甯革紝鑰屽悗浠?<code>alert()</code> 灝?<code>test.html</code> 鐨勫唴瀹瑰垪鍑?<o:p></o:p></li> </ul> <p>浣犲彲浠?a target="_blank">鐢辨嫻嬭瘯鏈緥</a> (<i><a target="_blank" >http://www.w3clubs.com/mozdev/httprequest_test.html</a></i>)錛屼篃鍙互鍙傝?a target="_blank">嫻嬭瘯妗f</a> (<i><a target="_blank" >http://www.w3clubs.com/mozdev/test.html</a></i>)銆?br /><o:p></o:p></p> <h2>絎洓姝?鈥?銆孹 妗f銆嶏紙鍙堢О涓恒屽鐞?XML 鍝嶅簲鍊箋嶏級 <o:p></o:p></h2> <p>鍓嶉潰鐨勪緥瀛愪腑錛屽湪鏀跺埌 HTTP 浼犲洖鍊煎悗鎴戜滑浠ュ璞$殑 <code>reponseText</code> 灞炴т嬌鐢?<code>test.html</code> 妗f鐨勫唴瀹癸紝鎺ョ潃鏉ヨ瘯璇?<code>responseXML</code> 灞炴х殑鏂規硶銆?<o:p></o:p></p> <p>棣栧厛錛屾垜浠緱鍋氫釜鏍煎紡姝g‘鐨?XML 鏂囦歡錛屼互渚跨◢鍚庡彇鐢ㄣ傛妗e悕鍞?<code>test.xml</code>錛屽唴瀹瑰涓嬶細</p> <p> <br /> <o:p> </o:p> </p> <div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"> <!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--> <span style="color: rgb(0, 0, 255);"><?</span> <span style="color: rgb(255, 0, 255);">xml聽version="1.0"聽</span> <span style="color: rgb(0, 0, 255);">?></span> <span style="color: rgb(0, 0, 0);"> <br /> <br /> </span> <span style="color: rgb(0, 0, 255);"><</span> <span style="color: rgb(128, 0, 0);">root</span> <span style="color: rgb(0, 0, 255);">></span> <span style="color: rgb(0, 0, 0);"> <br /> <br />聽聽聽聽I'm聽a聽test.<br /><br /></span> <span style="color: rgb(0, 0, 255);"></</span> <span style="color: rgb(128, 0, 0);">root</span> <span style="color: rgb(0, 0, 255);">></span> </div> <o:p> </o:p> <p> <br /> </p> <p>鍦ㄧ▼搴忎腑錛屾垜浠彨鐢ㄦ。妗堢殑鍦版柟鍙』鐣ヤ簨淇敼濡備笅錛?<o:p></o:p></p> <pre>...<o:p></o:p></pre> <pre> <div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"> <!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--> <span style="color: rgb(0, 0, 0);">onclick</span> <span style="color: rgb(0, 0, 0);">=</span> <span style="color: rgb(0, 0, 0);">"</span> <span style="color: rgb(0, 0, 0);">makeRequest('test.xml')</span> <span style="color: rgb(0, 0, 0);">"</span> </div> <o:p> </o:p> </pre> <pre>...<o:p></o:p></pre> <p>鎺ョ潃鍦?<code>alertContents()</code> 涓紝鎴戜滑蹇呴』灝?<code>alert(http_request.responseText);</code> 鏀規垚榪欐牱錛?/p> <p> <br /> <o:p> </o:p> </p> <div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"> <!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--> <span style="color: rgb(0, 0, 255);">var</span> <span style="color: rgb(0, 0, 0);">聽xmldoc聽</span> <span style="color: rgb(0, 0, 0);">=</span> <span style="color: rgb(0, 0, 0);">聽http_request.responseXML;<br /><br /></span> <span style="color: rgb(0, 0, 255);">var</span> <span style="color: rgb(0, 0, 0);">聽root_node聽</span> <span style="color: rgb(0, 0, 0);">=</span> <span style="color: rgb(0, 0, 0);">聽xmldoc.getElementsByTagName('root').item(</span> <span style="color: rgb(0, 0, 0);">0</span> <span style="color: rgb(0, 0, 0);">);<br /><br />alert(root_node.firstChild.data);</span> </div> <br /> <o:p> </o:p> <br />榪欐牱涓鏉ユ垜浠究鍙彇寰?<code>responseXML</code> 鎵浼犲洖鐨?<code>XMLDocument</code> 瀵硅薄錛岃屽悗浠?DOM 鐩稿叧鐨勬柟娉曞彇鐢?br />XML 鏂囦歡鍐呭銆備綘鍙互鍙傝?<a target="_blank"><code>test.xml</code> 鐨勫師濮嬬爜</a> (<i><a target="_blank" >http://www.w3clubs.com/mozdev/test.xml</a></i>)<br />浠ュ強淇敼榪囧悗鐨?a target="_blank">嫻嬭瘯紼嬪簭</a> (<i><a target="_blank" >http://www.w3clubs.com/mozdev/httprequest_test_xml.html</a></i>)銆?img src ="http://www.tkk7.com/paulwong/aggbug/44684.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/paulwong/" target="_blank">paulwong</a> 2006-05-05 22:21 <a href="http://www.tkk7.com/paulwong/articles/44684.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item></channel></rss> <footer> <div class="friendship-link"> <p>感谢您访问我们的网站,您可能还对以下资源感兴趣:</p> <a href="http://www.tkk7.com/" title="亚洲av成人片在线观看">亚洲av成人片在线观看</a> <div class="friend-links"> </div> </div> </footer> 主站蜘蛛池模板: <a href="http://luyifeile.com" target="_blank">日本高清免费中文在线看</a>| <a href="http://bovch.com" target="_blank">亚洲a∨无码一区二区</a>| <a href="http://meixiudashi.com" target="_blank">a毛片全部免费播放</a>| <a href="http://3bmmatv.com" target="_blank">国产亚洲精午夜久久久久久</a>| <a href="http://www678678.com" target="_blank">污网站免费在线观看</a>| <a href="http://zkqzdq.com" target="_blank">亚洲?V乱码久久精品蜜桃</a>| <a href="http://hivzx.com" target="_blank">免费国产在线精品一区</a>| <a href="http://286513.com" target="_blank">亚洲成人一区二区</a>| <a href="http://612662.com" target="_blank">a免费毛片在线播放</a>| <a href="http://tbw77.com" target="_blank">亚洲综合伊人久久综合</a>| <a href="http://4husese.com" target="_blank">a级毛片高清免费视频</a>| <a href="http://mironpress.com" target="_blank">亚洲av无码一区二区三区不卡 </a>| <a href="http://yu388.com" target="_blank">亚洲av乱码中文一区二区三区</a>| <a href="http://chiguigu.com" target="_blank">成人免费视频小说</a>| <a href="http://35469642.com" target="_blank">亚洲欧美在线x视频</a>| <a href="http://nn227.com" target="_blank">亚洲AV之男人的天堂</a>| <a href="http://sdhgjscl.com" target="_blank">中文字幕免费在线看线人动作大片</a>| <a href="http://lzqzvip.com" target="_blank">亚洲精品乱码久久久久久中文字幕 </a>| <a href="http://fholaer.com" target="_blank">51视频精品全部免费最新</a>| <a href="http://xwy2.com" target="_blank">亚洲午夜精品一区二区公牛电影院 </a>| <a href="http://zblinghang.com" target="_blank">好爽好紧好大的免费视频国产</a>| <a href="http://vip98888.com" target="_blank">国产精品久久久久久亚洲小说</a>| <a href="http://k4h3.com" target="_blank">亚洲精品线路一在线观看</a>| <a href="http://www876444.com" target="_blank">中文字幕无码日韩专区免费</a>| <a href="http://yytengsheng.com" target="_blank">亚洲视频在线观看网址</a>| <a href="http://taixin668.com" target="_blank">国外成人免费高清激情视频</a>| <a href="http://591se591se.com" target="_blank">男人j进女人p免费视频</a>| <a href="http://lswqn.com" target="_blank">亚洲精品免费在线观看</a>| <a href="http://zhaofeiz.com" target="_blank">操美女视频免费网站</a>| <a href="http://bbav04.com" target="_blank">伊人久久国产免费观看视频</a>| <a href="http://szjmlr.com" target="_blank">亚洲国产天堂久久综合网站</a>| <a href="http://szyujiaxing.com" target="_blank">无码日韩人妻av一区免费</a>| <a href="http://xianzijie.com" target="_blank">特级毛片爽www免费版</a>| <a href="http://327www.com" target="_blank">精品亚洲成a人片在线观看少妇</a>| <a href="http://93qsgy.com" target="_blank">女人18毛片a级毛片免费</a>| <a href="http://01shanzhai.com" target="_blank">h视频在线观看免费</a>| <a href="http://18736374.com" target="_blank">亚洲无线一二三四区</a>| <a href="http://cc006.com" target="_blank">一本久到久久亚洲综合</a>| <a href="http://ivr69.com" target="_blank">99久久精品免费精品国产</a>| <a href="http://adcacs.com" target="_blank">狠狠入ady亚洲精品</a>| <a href="http://786087.com" target="_blank">亚洲邪恶天堂影院在线观看</a>| <script> (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })(); </script> </body>