XDomainRequest - Doesn't Call ... Does Nothing

I have a problem ... I am using jQuery ajax to call a web service that returns XML. JQuery ajax stuff works amazingly for every browser except i.e.

So, for browsers, I use XDomainRequest. Here is the code:

if ($.browser.msie && window.XDomainRequest) {
    // Use Microsoft XDR
    var xdr = new XDomainRequest();
    xdr.open("get", theUserUrl);
    xdr.timeout = 95000;
    xdr.onerror = function () {
        console.log('we have an error!');
    }
    xdr.onprogress = function () {
        console.log('this sucks!');
    };
    xdr.ontimeout = function () {
        console.log('it timed out!');
    };
    xdr.onopen = function () {
        console.log('we open the xdomainrequest');
    };
    xdr.onload = function () {
        // XDomainRequest doesn't provide responseXml, so if you need it:
        var xml2 = new ActiveXObject("Microsoft.XMLDOM");
        xml2.async = false;
        xml2.loadXML(xdr.responseText);
        console.log('do we get any response text at all?: ' + xdr.responseText);
        ParseOwnershipObjects(xml2);
        //AddServiceRequestsToMap(xml2, map, spinner);
    };
    xdr.send();
}
  • This exact code works fine elsewhere in the application using a different URL.

    The url is ok, it returns exactly what it should in the browser (and therefore why jquery ajax call works). A couple of things to note:

    I am integrating my own html / javascript with another guy asp.net project.

In the file global.asax.csI have:

protected void Application_BeginRequest(object sender, EventArgs e)
{
    HttpContext.Current.Response.AddHeader("Access-Control-Allow-Origin", "*");
    HttpContext.Current.Response.AddHeader("Access-Control-Allow-Methods", "GET,OPTIONS");
}

therefore, I do not think this is a header problem.

None of my handlers fire. Not onprogress, ontimeout, onerror ... nothing! I don’t have time to convert web service to JSON.

?

!

+3
2

, url , XDomainRequest. GET POST -.

EDIT - - JSON, XDomainRequest. JSON , !

+1

- "XDomainRequest" - jQ jsonp xdomain...

- IE Dev (F12)? , , console.log

EDIT: mea culpa, jsonp - XML


Update:

XDomainRequest. theUserUrl.

  • /, Internet Explorer, console is undefined - , " ".

  • IE dev ( ), xdr.onerror. we have an error IE. , , .

Internet Explorer Dev Tools Consoloe

XDomainRequest , Access-Control-Allow-Origin. , , , , xdr.onerror.

+2

All Articles