0

I have a certain xml answer in a server which I want to use as origin in an AJAX request from my page. The server is properly configured so that cross-domain requests work.

The problem is the content type - it's fixed to 'text/html', and I can't change that.

Most browsers seem happy to accept an XML response with that content type. So far my code works in any recent version of Firefox, Chrome and Safari.

Internet Explorer 8 is giving me trouble, though.

I've prepared a jsfiddle trying to simulate my issue:

http://jsfiddle.net/LPa45/4/

On that jsfiddle, an AJAX request is made to the /echo/html service (which returns 'text/html' in the content type) but then it's used as an xml response. The "accepts" parameter, even if set for this specific purpose, doesn't really affect anything - I can remove it and everything works on FF, Chr too.

But I can't make it work on IE8. Does anyone have any hints?

Thanks!

kikito
  • 51,734
  • 32
  • 149
  • 189

2 Answers2

1

Looking at the console output (I'm using IE9 in IE8 mode so this may not be the same in pure IE8) it errors because the Array.Map() function is unavailable. Googling seems to suggest this was added in IE9.

See this answer for a map function you can use which should fix your issue.

Fiddle: http://jsfiddle.net/WvmBL/

Community
  • 1
  • 1
akiller
  • 2,462
  • 22
  • 30
1

The problem was that I thought the same-origin policy had been solved by the Access-Control-Allow-Origin "*" directive to Apache, but it turns out that IE8 doesn't respect it.

The only option I had was implementing a makeshift proxy server.

But!

Once the proxy server was up an running, I hit exactly the problem akiller is mentioning and answering - IE8 doesn't have an Array.map.

So, I'm marking is answer as correct, but keep in mind that it is not the whole answer! You need a proxy too.

Community
  • 1
  • 1
kikito
  • 51,734
  • 32
  • 149
  • 189