Fallenreaper
Fallenreaper

Reputation: 10704

Internet Explorer CrossDomain Request doesnt work correctly and MS doesnt give onerror reasoning

I added variables in the request as per the Microsoft standard below, var openRetVal and var sendRetVal... Odd thing is, that they dont get anything returned in them, so did Microsoft lie in their own documentation?

I was working on a ajax request, and like usual, IE is a difficult specimen to work with. I found that instead of doing a AJAX request, i can do an XDR. My code in chrome works, so i know the destination server is working and on a successful request does what is suppose to happen. Below is my code segment for an XDR.

if ($.browser.msie && window.XDomainRequest) {
            var xdr = new XDomainRequest();
            //var webstring = location.protocol +"//"+ location.host +"/" + WEBSERVICE_URL + "/test";
            //WEBSERVICE_URL = "webservices/FormDesigner.svc";
            var webstring = WEBSERVICE_URL + "/test";
            var openRetVal = xdr.open("GET", webstring);  //added this var as it supposidly gets a return value from the function call.
            xdr.onload = function () {
                var JSON = $.parseJSON(xdr.responseText);
                if (JSON == null || typeof (JSON) == 'undefined') {
                    JSON = $.parseJSON(data.firstChild.textContent); 
                }
                //below is my onsuccess call which is called by both successes for IE and NON-IE processes allowing all stuff to be piped into 1 call.
                ajax_success(JSON);
            };
            xdr.ontimeout = function () {
                alert("XDR Error.  Timeout");
            }
            xdr.onerror = function () {
                alert("XDR Error.  Unable to do a Cross Domain Server Request.");
            };
            var sentRetVal = xdr.send();  //added this var as the function is suppose to return success or error as per microsoft.

        }

It always returns onerror which is NOT what i am aiming for, naturally. I am pinging something within the same domain for the moment for testing purposes which is why there is not other stuff. Like i said, it works with other browsers so far... Is there an improper formatting I am unaware of? There is no data submitted as well with this test request.

Upvotes: 0

Views: 517

Answers (1)

Naftali
Naftali

Reputation: 146360

If you are already using jQuery, just use jQuery for ALL BROWSERS, then you should not have any issues in IE.

Upvotes: 3

Related Questions