GET request does not receive data in codef, but works in browser tab
This is my codepen for a simple weather app I made a long time ago. However, it does not work now. When I insert the tab api
into the browser, I get the data, but in codeden it doesn't work.
var api = "http://api.openweathermap.org/data/2.5/weather?
q=Lam%20Tin,HK&appid=23a5271ef6a94716ac17ec27e9f4bcd8";
$.getJSON(api, function(data) {
console.log(data);
});
source to share
Mistake
The page at 'https://codepen.io/iamanoopc/pen/JEjYKR?editors=0011' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://api.openweathermap.org/data/2.5/weather?q=Lam%20Tin,HK&appid=23a5271ef6a94716ac17ec27e9f4bcd8'. This request has been blocked; the content must be served over HTTPS.
Explanation
as shown very clearly. HTTPS, but requested an insecure XMLHttpRequest
.Is a secure domain server https
. Your http call is not secure. For security reasons they will block your requestThis request has been blocked; the content must be served over HTTPS
Alternative
Try with insecure http
snippet of domain server like jsbin
source to share