Amy Johnson
Amy Johnson

Reputation: 125

This request has been blocked; the content must be served over HTTPS

I try to do ajax, my code written on a https site it request to non https, but the resources were blocked by Chrome.

            $.ajax({
                url : "http://example.com/non-https",
..
..

Previously in earlier version I don't have this issue. Must my ajax request target a https too? Or there is a better way to save that problem?

Upvotes: 6

Views: 18633

Answers (1)

PalDev
PalDev

Reputation: 564

Just change the http:// in your url variable to //, so when the page is loaded with http, the ajax request would use the http protocol, if loaded with https, the ajax request protocol would be set by the browser to https. i.e, your code should look like:

           $.ajax({
                url : "//example.com/non-https",
..
..

Upvotes: 1

Related Questions