Things for geeks

April 14th, 2005
Posted by gerrod in: technical

XMLHttpRequest vs ActiveXObject: Microsoft actually invented the XMLHttpRequest, and yet it seems they handle it the worst out of all the browsers. For a start, you have to custom build your javascript to check for their browser. Then, you have to be able to support older browser versions!

function GetXmlHttpRequestObject() {
    // branch for native XMLHttpRequest object
    if (window.XMLHttpRequest) {
        return new XMLHttpRequest();

    // branch for IE/Windows ActiveX version
    } else if (window.ActiveXObject) {
        var xmlHttpObj = new ActiveXObject("Msxml2.XMLHTTP");
        if (!xmlHttpObj) {
            xmlHttpObj = new ActiveXObject("Microsoft.XMLHTTP");
        }

        return xmlHttpObj;
    }
}

So thankfully it all works from here. But I found out yesterday that once an Internet Explorer window has sent the request, it will never re-send it to the same URL. Instead, it’s logic effectively says, “hey, I’ve already checked that for you, so I’ll save you sending it again – here’s the results!”. Rather annoying when you’re sending different values in the header, and hence you’re expecting different results. Grrr…. So I had to use the old “append a random number at the end of the URL to force the browser to think it’s a different URL” trick – worked a charm.

Needless to say, the whole thing worked first go in Firefox

Jetbrains: Best news for ages – the good folk at Jetbrains are working on an IDE for .NET V2. You can head to the site and check out a very early (and raw) preview of the unnamed IDE. (You can also suggest names to them for consideration!). The screenshot doesn’t give you much to go on, except the promise that it’s coming! I can’t wait to sign up to the early access program!

2 comments

#1 Ben April 14th, 2005 at 2:15 pm

That’s very exciting. Can’t wait to try it all out.

#2 gerrod April 14th, 2005 at 2:54 pm

Yeah… I wonder how far off the EAP is? And I wonder if it will run on all environments (i.e. will it work off Mono)?