Categories
Around The Web

The Art of Souvenirs

This photoset titled souvenirs has been circulating around the web for a few weeks now. It’s amazing. Pretty much how it works is the author took pictures of famous places, with a souvenir perfectly framed in the picture to overlay the situation. Just like the stereotypical picture of the Leaning Tower Of Piza, and the tourist holding it up. What makes it so cool is that it’s extremely well done.

Categories
Programming Software Web Development

xmlHttpReq.overrideMimeType() in IE7

This is just a little note for anyone doing xmlHttp work. I just encountered this situation this morning. As most web developers know IE7 introduces support for the native scriptable XMLHttpRequest object. The big advantage here is that ActiveX is no longer necessary to use ajax applications on IE. One thing I did note is that there is a slight difference in their support for the XMLHttpRequest object. Take the following code:

// Mozilla/Safari/IE7+
if (window.XMLHttpRequest) {
    xmlHttpReq = new XMLHttpRequest();
    xmlHttpReq.overrideMimeType(‘text/xml’);
}
// IE6-
else if (window.ActiveXObject) {
    xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlHttpReq.open(‘POST’, strURL, true);

That seems to break for me on IE7. A little experimentation shows that it doesn’t support the overrideMimeType() method. A simple fix for this is to simply check before invoking it as follows:

// Mozilla/Safari/IE7+
if (window.XMLHttpRequest) {
    xmlHttpReq = new XMLHttpRequest();
    if(xmlHttpReq.overrideMimeType){       
        xmlHttpReq.overrideMimeType(‘text/xml’);
    }
}
// IE6-
else if (window.ActiveXObject) {
    xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlHttpReq.open(‘POST’, strURL, true);

This is just FYI for anyone who happens to encounter this error. It’s a simple fix. This somewhat goes without saying, but make sure your request returns from the server as text/xml or you’ll likely still encounter issues.