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?
How to fix your website. The best strategy to avoid mixed content blocking is to serve all the content as HTTPS instead of HTTP. For your own domain, serve all content as HTTPS and fix your links. Often, the HTTPS version of the content already exists and this just requires adding an "s" to links - http:// to https://.
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",
..
..
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With