32

I'm trying to use microsoft XDomainRequest to send cross domain request. Here is the code

...
if ($.browser.msie && window.XDomainRequest) {
  // Use Microsoft XDR
  var xdr = new XDomainRequest();
    xdr.open("POST", "http://graph.facebook.com/1524623057/");

  xdr.send();
} 
 ....

It gives SCRIPT5: Access is denied. error on xdr.open(...) line.

Jonas
  • 97,987
  • 90
  • 271
  • 355
narek.gevorgyan
  • 3,957
  • 5
  • 29
  • 50

2 Answers2

58

I found the reason of this problem. As stated in Point 7:

Requests must be targeted to the same scheme as the hosting page

This restriction means that if your AJAX page is at http://example.com, then your target URL must also begin with HTTP. Similarly, if your AJAX page is at https://example.com, then your target URL must also begin with HTTPS.

Community
  • 1
  • 1
narek.gevorgyan
  • 3,957
  • 5
  • 29
  • 50
  • 2
    Point 7 being "Requests must be targeted to the same scheme as the hosting page". I was struggling with this same problem too, calling an **https** address from an **http** page. Thanks for the link! – Kaivosukeltaja Aug 09 '12 at 10:43
  • 2
    I understood that, but is there any way to fix this problem and can access https: ajax from http sites. – jforjs Dec 11 '14 at 06:20
  • this really help me a lot! I spend hours trying to figure out :) – Kenneth Palaganas Apr 10 '15 at 17:31
-1

See this:

http://msdn.microsoft.com/en-us/library/cc288060(v=vs.85).aspx

It describes how the server must respond with a certain header, Access-Control-Allow-Origin.

dnuttle
  • 3,571
  • 2
  • 17
  • 19