2016-05-26 64 views
0

https://codepen.io/RycerzPegaza/pen/pbzdgY 这是我的codepen,我尝试从天气API获取数据。提供JSON数据链接的作品,但没有什么在这里做的工作:

$.getJSON(temperature, function(data) { 
    cityName.innerHTML = data; 
    }); 

- 如果我改变数据测试字符串它也不起作用。 - “$ .get”不起作用

回答

1

这不是$ .getJSON的错误,只需打开bowser的控制台即可看到此错误。

jquery-2.2.4.min.js:4Mixed Content: The page at 'https://codepen.io/RycerzPegaza/pen/pbzdgY?editors=1111' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://api.openweathermap.org/data/2.5/weather?lat=31.277204800000003&lon=121.538243&APPID=7248ea2cccd4e2cd9b65fa7bd9cf6e9a&units=metric'. This request has been blocked; the content must be served over HTTPS. 

这是因为API提供的http,但是你的页面在https中运行,这会导致安全漏洞,所以bowser会阻止请求。