XHR response blocked by Chrome due to mixed content issue (http / https)

I am currently using jQuery AJAX to get the relative URL without the scheme / domain in front of it (for example, '/ js / get_international_popup /. The response is also the relative URL when I look at the header of my location before I return it.

When I test this locally, over HTTP, everything works as it should. However, as soon as I test it on my real server, the response is blocked by Chrome via HTTPS, because it says that it is unsafe:

Mixed content: The page at https://example.com/ 'was loaded via HTTPS, but requested the XMLHttpRequest' http://example.com/js/get_international_popup/ 'insecure endpoint. This request is blocked; content must be transmitted via HTTPS.

From a Chrome perspective, my local test request / response went over HTTP, but my test request went through HTTPS and received an HTTP response. I cannot view the response of Chrome on a real server because it is blocked.

If I return a response with an absolute URL (including https: // domain ), everything works fine, but I prefer not to use an absolute URL.

Does anyone know if there is a way to fix this problem using relative URLs?

+7
jquery google-chrome ajax mixed-content
source share
1 answer

add this using javascript:

var relative_url = '/js/get_international_popup/'; var absolute_url = window.location.origin + relative_url; $.ajax(absolute_url, function(){}); 

Ref: http://www.w3schools.com/jsref/prop_loc_origin.asp

Note: Not Tested

0
source

All Articles