18

I'm trying to do something like this (W3 compliant, DOM):

xhr.setRequestHeader( 'X-Requested-With', 'XMLHttpRequest' );

For ActiveXObject('Microsoft.XMLHTTP') and XDomainRequest (IE8). I'm having no such luck finding it anywhere in microsoft documentation or even google. Any idea how I can achieve this?

Jonas
  • 121,568
  • 97
  • 310
  • 388
ground5hark
  • 4,464
  • 8
  • 30
  • 35

1 Answers1

29

Referring to this post Link See the point three 3. No custom headers may be added to the request

You cannot add custom headers to an XDR object. Hope this helps.

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
Furqan Hameedi
  • 4,372
  • 3
  • 27
  • 34
  • 40
    MSIE shouldn't even exist. I hate that browser. Always breaking the Web. I only use it to download other browsers. And I don't even see how `XDomainRequest` is useful. – TheRealChx101 Feb 17 '13 at 02:12
  • 3
    @chx101, If it had not existed, we would not have been able to prefer others :). – Furqan Hameedi Feb 18 '13 at 07:34
  • 5
    @chk101: While I realise it's fun and easy to criticise MSIE years after the fact for its "missing" features, it's definitely worth remembering that the first CORS working draft was introduced March 17, 2009 -- exactly two days before IE8 was released. It didn't become a W3C Proposed Recommendation until December 2013. As a point of comparison, Firefox didn't support CORS in a production release until summer 2009 (version 3.5). – Warren Rumak Dec 09 '13 at 19:38
  • 1
    @Warren So I should feel bad for microsoft deciding to force a broken update model onto its consumers? – Robert Christ Jan 13 '14 at 23:02
  • 4
    I'm not in a position to advise you on your feelings -- I'm just outlining the history as it happened five years ago. (People sometimes forget what order things happened) – Warren Rumak Jan 13 '14 at 23:25
  • 2
    Note that Firefox supported CORS less than half a year after the working draft was introduced. IE didn't support credentialed requests until IE10, September 2012. – Ajax Aug 01 '14 at 00:18
  • @Furqan the post you have mentioned is about XDR, but can we set a custom http header to the Microsoft.XMLHTTP? – ZhaoGang Nov 11 '16 at 10:01
  • @ZhaoGang at the time of this post(in 2010) , with IE 8 it did not support that. It does now. – Furqan Hameedi Nov 14 '16 at 09:24