简体   繁体   English

我无法从JSON文件获取数据-$ .getJSON不起作用

[英]I Can't get data from JSON file - $.getJSON doesn't work

https://codepen.io/RycerzPegaza/pen/pbzdgY This is my codepen where I try to get data from a weather API. https://codepen.io/RycerzPegaza/pen/pbzdgY这是我的Codepen,我在这里尝试从天气API中获取数据。 The link providing JSON data works, but none of what do here works: 提供JSON数据的链接有效,但此处无效:

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

-If i change data to a test string it doesn't work either. -如果我将数据更改为测试字符串,则也不起作用。 - "$.get" doesn't work either -“ $ .get”也不起作用

It's not an error with $.getJSON,just open the console of you bowser you will see this error. 这不是$ .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.

This is because the API provide by http but you page run in https,this will cause a security hole, so the bowser block the request. 这是因为该API由http提供,但您的页面在https中运行,这会导致安全漏洞,因此Bowser阻止了该请求。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM