0

I have a site at myapp.myurl.com that is making an ajax request to api.myurl.com. I understand that this is considered "cross-domain." What I don't understand is why the ajax call works in every browser except IE8 and IE9.

Here's the code with details removed.

 $.ajax({
    type: "POST",
    dataType: "json",
    headers: header,
    data: data,
    url: "api.myurl.com/getdata",
    success: function (data) {
    //dostuff
    }
});

Is there anything I can do?

Here's the response when I run the script manually in IE8

{readyState: 0, responseJSON: undefined, status: 0, statusText: "No Transport"}

Here's the response when I run the script manually in Chrome

Object {readyState: 1, getResponseHeader: function, getAllResponseHeaders: function, setRequestHeader: function, overrideMimeType: function…}

And it has the correct JSON response.

joelforsyth
  • 836
  • 1
  • 11
  • 28
  • @A.Wolff none. It just simply doesn't make the request. – joelforsyth Apr 29 '15 at 16:24
  • also dataType of call would be helpful ...json, jsonp etc as well as showing code used – charlietfl Apr 29 '15 at 16:24
  • @charlietfl I updated my question. Data and header are json format. – joelforsyth Apr 29 '15 at 17:55
  • have you even confirmed the request is being made (see network tab in dev tools)? Any errors thrown? – charlietfl Apr 29 '15 at 17:58
  • @charlietfl Yes, I can confirm (with results and Fiddler) that I the request is being made in every browser except IE8 and 9. If I watch the traffic with those browsers, the request isn't even attempted. No errors at all. – joelforsyth Apr 29 '15 at 18:00
  • if request not even attempted then it sounds like a problem in code that initiates request. i'm not really familiar with any specific IE issues that would prevent it – charlietfl Apr 29 '15 at 18:01
  • @charlietfl I added the result of when I manually run the ajax call in the browsers – joelforsyth Apr 29 '15 at 18:22
  • jQuery doesn't not provide the functionality required to perform CORS requests in browsers that do not support XHR2. Your only option is to either do the request without jquery, or implement a transport in jQuery that will properly handle it. – Kevin B Apr 29 '15 at 18:25

2 Answers2

2

IE 8 and 9 have only a partial CORS implementation. They also use a non-standard object called XDomainRequest to to cross-domain requests.

You may need to write some special code to do it, or use a special jquery plugin.

See this other post which describes similar issues. CORS with jQuery and XDomainRequest in IE8/9

Community
  • 1
  • 1
Raul Nohea Goodness
  • 2,549
  • 23
  • 24
0

I was not able to find a working solution to posting cross domain (ones that included upgrading to a later version of WebAPI weren't possible).

I solved the issue by creating a POST method in the site's controller and then posting to the web API from the server.

joelforsyth
  • 836
  • 1
  • 11
  • 28