0

I am making various cross domain ajax calls to various endpoints. This works just fine in Chrome, Firefox and IE 10 and 11 however it is not working in IE8 and IE9. I am getting the following error in the console:

[object Object]{readyState: 0, status: 0, statusText: "No Transport"}

The ajax code I am using is the following:

 $.getJSON(url).done(function (data) {
        console.log(data);
            //Do stuff based on response
        }).fail(function (data){
            //Do stuff based on response
        });

I have tried adding the following due to others saying it might work:

$.support.cors = true;

However I am still receiving the same error.

I have read that IE8 and IE9 do not support ajax calls and that I need to use xdr.

I have tried that as well but am not having any luck the following is the code I tried:

var xdr = new XDomainRequest();
xdr.onload = function () {
    console.log(xdr.responseText);
}
xdr.onerror = function () { /* error handling here */ }
xdr.open('GET', url);
xdr.send();

However, this is not working either. It is very possible I am doing something wrong since I have never worked with xdr before.

The console.log is outputting the following:

<!doctype html>
<html lang="en-us">
<head>
<title>SubscriberExists Snapshot of 6/13/2015 12:12:22 AM</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">

So, I guess I have a few questions:

  1. Is the onload and onerror the same as the .done and .fail for jquery?

  2. If not how can I do things based off a success or fail response?

  3. Basically if anyone can help me translate the ajax call I am making into the xdr equivalent. I would greatly appreciate the help.

Caleb
  • 21
  • 4
  • What version of jQuery are you using ? – adeneo Jun 13 '15 at 00:53
  • @adeneo I am using jquery 1.11.3 – Caleb Jun 13 '15 at 00:58
  • I've got nothing, `$.support.cors = true` before the ajax request should work as far as I know? – adeneo Jun 13 '15 at 01:02
  • Have you tried this? https://github.com/MoonScript/jQuery-ajaxTransport-XDomainRequest – Brian Jun 13 '15 at 01:04
  • @Brian yes I tried that and I am still getting a No Transport. Could this be caused by the fact the page is https? – Caleb Jun 13 '15 at 13:35
  • No, SSL shouldn't effect this... it's possible the error is on the server side... XDomainRequest is the way to handle this, so it should work. There can be server side issues, such as this http://stackoverflow.com/questions/19245449/posting-cross-domain-ajax-xdomainrequest-to-web-service. Do you own the server? If not, you might have to reach out to who does... – Brian Jun 13 '15 at 16:04

0 Answers0