new XMLHttpRequest in IE9 causes a JScript runtime error: Object doesn't support this property or method

happens only in IE9 (in firefox it works fine) tried lowering the security settings to minimum. i'm not sure about other versions of IE because i have 9 installed.

Environment: 3.5 webforms scripting frameworks: Anthem.NET, jquery

the anthem script is trying to create an instance of XMLHttpRequest and fails i tried just create it myself on the page and had the same error. on the same project i've created a new html page and it worked fine.

so it might be some scripting collusion...


Here is the original code that fails (on line 3) taken from the Anthem.NET framework that runs on the system:

function Anthem_GetXMLHttpRequest() {
if (window.XMLHttpRequest) {  // <-- This passes as True! window.XMLHttpRequest is {...}
    return new XMLHttpRequest(); // <---- Fails here
} else {
    if (window.Anthem_XMLHttpRequestProgID) {
        return new ActiveXObject(window.Anthem_XMLHttpRequestProgID);
    } else {
        var progIDs = ["Msxml2.XMLHTTP.6.0", "Msxml2.XMLHTTP.5.0", "Msxml2.XMLHTTP.4.0", "MSXML2.XMLHTTP.3.0", "MSXML2.XMLHTTP", "Microsoft.XMLHTTP"];
        for (var i = 0; i < progIDs.length; ++i) {
            var progID = progIDs[i];
            try {
                var x = new ActiveXObject(progID);
                window.Anthem_XMLHttpRequestProgID = progID;
                return x;
            } catch (e) {
return null;


here's the Window.XMLHttpRequest value:

and here is a picture of the failure that i created myself:

Update: Just found out that it works in Compatibility Mode ! and when i go back to normal mode it works again! BTW: the document mode is on Quirks mode (which is the default)


Recently I ran into the problem and I found that if I place the code which creates the XMLHttpRequest inside of a function that runs once the window loads that it works fine every time. Try placing your code in this:

window.onload = function() {
    var lala = new XMLHttpRequest();

Or if you use jquery:

$(function() {
    var lala = new XMLHttpRequest();

In IE (< v.9 )window#XMLHttpRequest is undefined as this is a browser specific global Object (i.e. for W3C conformant browsers such as the Mozilla or Webkit based browsers as well as Opera).

I don't really understand myself why


does not evaluate to false but well nothing you can do there.

What you can do however is add a code fork before that to check for window#ActiveXObject (i.e. Internet Explorer)

if(!! window.ActiveXObject) { // same as typeof window.ActiveXObject !== "undefined"
    /* use MSXML */
else if(!! window.XMLHttpRequest) {
    /* use XMLHttpRequest */
else throw Error("Browser does not support XHR.") ;

If you cannot modify the source code at this point and the problem persists you might want want to change frameworks.

Edit: I just now noticed that you were saying the problem shows up in IE 9. That should actually not be the case as IE 9 supports the XMLHttpRequest Object.

Believe it or not, ie9 DOES NOT actually support XMLHttpRequest (you can change some settings in your internet options as the end-user, but I'm sure that's not gonna be an acceptable answer to your boss).

For ie9, you gotta do this:

var xmlhttp;
if (ie9)
    xmlhttp=new XDomainRequest();
    xmlhttp=new XMLHttpRequest();

Then, where you'll normally apply (for regular browsers):

     if (xmlhttp.readyState==4 && xmlhttp.status==200)
          // do your thing

You'll have to do this instead (for ie9):

if (this.ie9)
     xmlhttp.onload = function()
         // do your ie9 thing

Need Your Help

JavaMail to send email through vps, require NO authentication, but get AuthenticationFailedException - why?

java email authentication smtp javamail

I originally setup my site to use my local ISP to send email through my site. I would like to change this, and start sending email through my VPS. According to the online documentation (from my vps

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.