Changeset 7961
- Timestamp:
- 04/06/07 17:11:34 (21 months ago)
- Location:
- dojo/trunk/_base/_loader
- Files:
-
- 2 modified
-
hostenv_browser.js (modified) (3 diffs)
-
loader.js (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
dojo/trunk/_base/_loader/hostenv_browser.js
r7947 r7961 91 91 } 92 92 } 93 94 /*if(http && !http.toString) {95 http.toString = function() { "[object XMLHttpRequest]"; }96 }*/97 93 } 98 94 … … 111 107 } 112 108 113 d._blockAsync = false; 114 d._getText = function(uri, async_cb, fail_ok){ 109 d._getText = function(uri, fail_ok){ 115 110 // summary: Read the contents of the specified uri and return those contents. 116 111 // uri: 117 112 // A relative or absolute uri. If absolute, it still must be in 118 113 // the same "domain" as we are. 119 // async_cb:120 // If not specified, load synchronously. If specified, load121 // asynchronously, and use async_cb as the progress handler which122 // takes the xmlhttp object as its argument. If async_cb, this123 // function returns null.124 114 // fail_ok: 125 // Default false. If fail_ok and !async_cb and loading fails, 126 // return null instead of throwing. 127 128 // need to block async callbacks from snatching this thread as the result 129 // of an async callback might call another sync XHR, this hangs khtml forever 130 // hostenv._blockAsync must also be checked in BrowserIO's watchInFlight() 115 // Default false. If fail_ok and loading fails, return null 116 // instead of throwing. 117 131 118 // NOTE: must be declared before scope switches ie. this._xhrObj() 132 if(!async_cb){ this._blockAsync = true; }133 134 119 var http = this._xhrObj(); 135 120 136 if(async_cb){ 137 var _this = this, timer = null, gbl = dojo.global(); 138 http.onreadystatechange = function(){ 139 if(timer){ gbl.clearTimeout(timer); timer = null; } 140 if(_this._blockAsync){ 141 timer = gbl.setTimeout(function(){ 142 http.onreadystatechange.apply(this); 143 }, 10); 144 }else{ 145 if(4==http.readyState){ 146 if(isDocumentOk(http)){ 147 // console.debug("LOADED URI: "+uri); 148 async_cb(http.responseText); 149 } 150 } 151 } 152 } 153 } 154 155 http.open('GET', uri, async_cb ? true : false); 121 http.open('GET', uri, false); 156 122 try{ 157 123 http.send(null); 158 if(async_cb){159 return null;160 }161 124 if(!isDocumentOk(http)){ 162 125 var err = Error("Unable to load "+uri+" status:"+ http.status); … … 166 129 } 167 130 }catch(e){ 168 this._blockAsync = false; 169 if((fail_ok)&&(!async_cb)){ 170 return null; 171 }else{ 172 throw e; 173 } 174 } 175 176 this._blockAsync = false; 131 if(fail_ok){ return null; } 132 throw e; 133 } 177 134 return http.responseText; // String 178 135 } -
dojo/trunk/_base/_loader/loader.js
r7882 r7961 108 108 return true; // Boolean 109 109 } 110 var contents = this._getText(uri, null,true);110 var contents = this._getText(uri, true); 111 111 if(!contents){ return false; } // Boolean 112 112 this._loadedUrls[uri] = true;