TechnoMagicians Blog

Any sufficiently advanced technology is indistinguishable from magic – Arthur C. Clarke.

TechnoMagicians Blog header image 2

Native XMLHTTPRequest In IE7

June 1st, 2006 · No Comments

As Sunava Dutta points out, IE7 now includes a native XMLHTTPRequest object along side support of the ActiveX object as well.

In looking into a BlogChat bug with IE7 Beta with help from Sunava and others from MS we have determined that the ActiveX implementation in IE7 doesn't work exactly the same as pre-IE7 browsers. Brent had a theory about what was happening, although he mistakenly thought we were using the native object at the time. It seems it is the ActiveX implementation in IE7 that is refiring or some such thing.

Folks should be cautious with their AJAX implementations in supporting IE7 and make sure they instantiate a native object in IE7 instead of the ActiveX one.

One way to do this was posted by Joe Walker here.

And I'll post from the current Dojo source code (revision 4219). Please forgive the formatting as I don't feel like editing it myself:

102     // These are in order of decreasing likelihood; this will change in time.
103     dojo.hostenv._XMLHTTP_PROGIDS = ['Msxml2.XMLHTTP', 'Microsoft.XMLHTTP', 'Msxml2.XMLHTTP.4.0'];
105     dojo.hostenv.getXmlhttpObject = function(){
106         var http = null;
107             var last_e = null;
108             try{ http = new XMLHttpRequest(); }catch(e){}
109         if(!http){
110                     for(var i=0; i<3; ++i){
111                             var progid = dojo.hostenv._XMLHTTP_PROGIDS[i];
112                             try{
113                                     http = new ActiveXObject(progid);
114                             }catch(e){
115                                     last_e = e;
116                             }
118                             if(http){
119                                     dojo.hostenv._XMLHTTP_PROGIDS = [progid];  // so faster next time
120                                     break;
121                             }
122                     }
124                     /*if(http && !http.toString) {
125                             http.toString = function() { “[object XMLHttpRequest]”; }
126                     }*/
127             }
129             if(!http){
130                     return dojo.raise(“XMLHTTP not available”, last_e);
131             }
133             return http;
134     }

Category: General


0 responses so far ↓

  • There are no comments yet...Kick things off by filling out the form below.

Leave a Comment