Skip to content Skip to sidebar Skip to footer

Https Xmlhttprequest Failing To Retrieve Correct Page

I am trying to get content of a page, but this page is secured using https. I tried to use XMLHttpRequest with a http site and succeeded, but this page does return the redirect of

Solution 1:

You can't make AJAX requests cross-domain, unless it returns a Access-Control-Allow-Origin header. Cross-site HTTP requests initiated from within scripts have been subject to well-known restrictions, for well-understood security reasons. For example HTTP Requests made using the XMLHttpRequest object were subject to the same-origin policy. In particular, this meant that a web application using XMLHttpRequest could only make HTTP requests to the domain it was loaded from, and not to other domains.

More information: https://developer.mozilla.org/en-US/docs/HTTP/Access_control_CORS

You could bypass this using a PHP Proxy: http://blog.edwards-research.com/2012/10/cross-domain-ajax-a-simple-workaround/

Post a Comment for "Https Xmlhttprequest Failing To Retrieve Correct Page"