0

I have a https Web Page. I call another http webpage by JavaScript inside.

The alert shows Access Denied.

Here is my code.

var url = "http://127.0.0.1:2737/video";
try {
    if (document.all) {
        var xdr = new XDomainRequest();
        xdr.open('GET', url)
        xdr.send();
    }
    else {
        var req = new XMLHttpRequest();
        req.open('GET', url, true);
        req.send(null);
    }
}
catch (e) {
    alert(e);
}

Please help me!

JoriO
  • 1,050
  • 6
  • 13

1 Answers1

1

I supose you are trying to do this with IE8 or IE9. Is that right? The problem of this is shown here:

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.

Thus, if this is the case, I am afraid it is not possible to do that

Michael
  • 3,308
  • 5
  • 24
  • 36
  • So, I have changed the way to call http page inside by using window.open(url). but I need closing that after It loads complete. Can you show me how to detect loading status of new page? – Đức Minh Phạm Nov 05 '14 at 08:45
  • 1
    If I got it correctly, the call is performed in the opened window? If that is so, you just have to add: req.onload = function(){ window.close(); } – Michael Nov 05 '14 at 08:59