聽 聽dojo.io鐨勮澶氫笉鍙濊鐨勫姛鑳介兘鐢眀ind()鏂規硶鏉ュ疄鐜般傦紙鍙兘鑴氭湰璇█鎴栦笉瀹氬弬鏁扮殑璇█閮藉枩嬈㈣繖鏍鳳紝璇村疄璇濓紝鎴戜笉鍠滄錛夈俤ojo.io.bind()鏄竴涓櫘閫氱殑鍖垮悕璇鋒眰API錛屽畠鐨勫簳灞傚彲浠ユ槸涓嶅悓鐨勪紶杈撴満鍒?queues of iframes, XMLHTTP, mod_pubsub, LivePage, 絳?銆俤ojo浼氬皾璇曢夋嫨鏈濂界殑浼犺緭鏈哄埗錛屽鏋滀綘鐨勭幆澧冩敮鎸佸縐嶄紶杈撴満鍒訛紝XMLHTTP浼氭槸dojo鐨勯閫夈俠ind()鏂規硶鐨勫弬鏁版槸涓涓畝鍗曠殑鍖垮悕瀵硅薄錛屽綋鐒惰繖涓璞$殑灞炴ф槸寮傚父鐏墊椿鐨勩?br />聽濡傛灉浣犺寰楀埌涓涓猼ext鏂囦歡錛屽彲鑳戒唬鐮佸涓嬶細
dojo.io.bind({
聽 聽url: "
http://foo.bar.com/sampleD...,
聽 聽load: function(type, data, evt){ /*do something w/ the data */ },
聽 聽mimetype: "text/plain"
});
鍜宲rototype.js/YUI絳夊樊涓嶅錛岀畝鍗曠殑浠g爜鍙互寰楀埌鏁版嵁銆傚彲鑳戒綘涔熸兂鍒幫紝濡傛灉鍑虹幇閿欒鎬庝箞 鍔烇紝綆鍗曟敞鍐屼竴涓敊璇鐞嗗嚱鏁板氨濂戒簡錛?br />dojo.io.bind({
聽 聽url: "
http://foo.bar.com/sampleD...,
聽 聽load: function(type, data, evt){ /*do something w/ the data */ },
聽 聽error: function(type, error){ /*do something w/ the error*/ },
聽 聽mimetype: "text/plain"
});
dojo涔熷彲浠ユ妸鎵鏈夌殑澶勭悊鏀懼埌涓涓嚱鏁伴噷錛屽涓?
dojo.io.bind({
聽 聽url: "
http://foo.bar.com/sampleD...,
聽 聽handle: function(type, data, evt){
聽 聽 聽 聽if(type == "load"){
聽 聽 聽 聽 聽 聽// do something with the data object
聽 聽 聽 聽}else if(type == "error"){
聽 聽 聽 聽 聽 聽// here, "data" is our error object
聽 聽 聽 聽 聽 聽// respond to the error here
聽 聽 聽 聽}else{
聽 聽 聽 聽 聽 聽// other types of events might get passed, handle them here
聽 聽 聽 聽}
聽 聽},
聽 聽mimetype: "text/plain"
});
鑰冭檻鎬ц兘鍘熷洜錛孉jax緇忓父閲嶆湇鍔″櫒榪斿洖涓孌靛彲鎵ц鐨刯avascript浠g爜孌碉紝鍦ㄦ祻瑙堝櫒涓璭val(瀹?銆備綘鍙鎸囧畾mimetype: "text/javascript" 灝?br />
鍙互浜嗭紝dojo浼氳嚜鍔ㄤ負浣?eval榪欎簺javascript浠g爜錛?br />
浣犱篃鍙互鎸囧畾浣犱嬌鐢ㄥ摢縐嶄紶杈撳櫒 濡?XMLHTTPTransport:
dojo.io.bind({
聽 聽url: "
http://foo.bar.com/sampleD...,
聽 聽load: function(type, evaldObj){ /* do something */ },
聽 聽mimetype: "text/plain", // get plain text, don't eval()
聽 聽transport: "XMLHTTPTransport"
});
Being a jack-of-all-trades, bind() also supports the submission of forms via a request (with the single caveat that it won't do file upload over XMLHTTP):
????寰楃湅鐪嬩唬鐮侊紵鏄惁url浼氳鐩朼ction.
dojo.io.bind({
聽 聽url: "
http://foo.bar.com/process...,
聽 聽load: function(type, evaldObj){ /* do something */ },
聽 聽formNode: document.getElementById("formToSubmit")
});
鍛靛懙錛屼笉閿欏惂銆備笅闈㈢湅鐪嬪嚑涓紶杈撳櫒銆?br />
Transports:
dojo.io.bind鍜屽叾瀹冪浉鍏沖嚱鏁頒笌鏈嶅姟鍣ㄩ氫俊鏈夊嚑縐嶆柟娉曪紝鍙玊ransport錛屾瘡縐峊ransports鍙兘閮芥湁緙洪櫡錛屽洜姝ゅ湪鐗瑰畾鍦哄悎浣犲繀欏婚夋嫨鍚堥傜殑transport銆?br />榛樿鐨則ransport鏄ぇ瀹剁啛鎮夌殑 XMLHttp.
XMLHttp
xmlhttp鍦ㄥぇ閮ㄥ垎鎯呭喌涓嬪伐浣滅殑寰堝ソ錛屼絾瀹冧笉鑳戒笂浼犳枃浠訛紝涓嶈兘璺ㄥ煙宸ヤ綔錛屼篃涓嶈兘鍦╢ile://鍗忚涓嬪伐浣溿傦紙dojo涔熶唬鏇跨殑鏂規錛?br />
渚嬪瓙浠g爜:
<script type="text/javascript"> 聽 dojo.require("dojo.io.*"); 聽
function mySubmit({ 聽 聽
聽 聽dojo.io.bind ({ 聽 聽 聽
聽 聽url: 'server.cfm', 聽 聽 聽
聽 聽handler: callBack, 聽 聽 聽 聽 聽
聽 聽formNode: dojo.byId('myForm') 聽 聽
聽}); 聽
} 聽
function callBack(type, data, evt) { 聽
聽 聽dojo.byId('result').innerHTML = data; 聽
}
</script>
IFrame I/O錛?/strong>
IFrame I/O transport鏄湁鐢ㄧ殑錛屽畠鍙互涓婁紶鏂囦歡. 聽渚嬪瓙浠g爜:
<script type="text/javascript"> 聽 dojo.require("dojo.io.*"); 聽
dojo.require("dojo.io.IframeIO");
function mySubmit() { 聽 聽
聽dojo.io.bind ({ 聽 聽 聽 聽 聽 url: 'server.cfm', 聽 聽 聽
聽 聽handler: callBack, 聽 聽 聽
聽 聽formNode: dojo.byId('myForm') 聽 聽 聽 }); 聽
} 聽
function callBack(type, data, evt) { 聽 聽 聽
聽dojo.byId('result').innerHTML = data; 聽
}
</script>
The response type from the above URL can be text, html, or JS/JSON.
榪欑鍝嶅簲綾誨瀷鐨剈rl鍙互鏄痶ext,html鎴栬卝s/json. 
]]>