使用HTTPS页面中的HTTP API [英] Using HTTP API from HTTPS page

查看:384
本文介绍了使用HTTPS页面中的HTTP API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是一名使用Windows 10家庭编辑的freecodecamp学生。 Codepen.io是一个http站点的编辑器。 本地天气课程让我从开放的天气图中得到一个api,这也是一个http。当我第一次:

I'm a freecodecamp student using windows 10 home edittion. Codepen.io the editor that is a http site. the "local weather" lesson has me with an api from open weather map which is also an http. When I first:

$.document.ready(function() {
  var api = "http://api.openweathermap.org/data/2.5                   /weather?id=2172797&appid=(I have my api key)";        
  $.getJSON(api, function(data) {
    alert(api, data.coord.lon);  
  });
});

我问其他编码员,他们说代码是正确的。我也试过AJAX:

I have asked other coder and they said the code is correct. I have also tried AJAX:

function loadDoc() {
  var url = "http://api.openweathermap.org/data/2.5/weather?id=2172797& appid=(I have my api key)";
  var xhttp = new XMLHttpRequest();
  xhttp.onreadystatechange = function() {
    if (xhttp.readyState == 4 && xhttp.status == 200) {
      document.getElementById("demo").innerHTML = xhttp.responseText;
    }
  };
  xhttp.open("GET", "url", true);
  xhttp.send();
}

我没有得到数据,也没有得到警报响应。然后我通过电子邮件发送了Codepen.io回复:

I don't get the data, nor do I get an "alert" response. I then emailed Codepen.io response:

我在这里看到的第一个问题是你是通过HTTPS访问Pen并通过HTTP请求Wikipedia API。发生这种情况时,您会收到混合内容警告。当您使用安全的HTTPS URL时,浏览器不允许您请求非安全URL。

The first problem I see here is you’re visiting the Pen over HTTPS and requesting the Wikipedia API over HTTP. You’ll get mixed content warnings when this happens. The browser doesn’t allow you to request non secure URLs when you’re on a secure HTTPS URL.

然后我尝试操作chrome,mozilla中的设置,和IE,仍然没有回应。我曾与编程人员通过电子邮件联系,称为centurylink,并与他们的程序员交谈过,已经将goDaddy称为证书,现在我发现自己仍然没有解决方案。我一直在使用Codepen的编辑器进行分配(这是通过电子邮件发送给我的实际的http网站)。我从5月29日开始研究这个问题而且我没有解决方案。

I then tried the to manipulate the settings in chrome, mozilla, and I.E., and still no responses. I have talked to coders, emailed, called centurylink and have talked to their programmers, have called goDaddy for a certificate, and now I find myself still with no solution. I have been using Codepen's editor for assignments (with is the actual, http site that emailed me). I have reseached this problem since MAY 29th and I have no solution.

有人可以提供帮助。谢谢。

Can someone help. Thank you.

推荐答案

您可以使用一台服务器代理它:App AJAX =>您的https服务器呼叫在后端(不是重定向)=> http API

You can proxy it with one server : App AJAX =>your https server call in back-end (not a redirect)=>The http API

这篇关于使用HTTPS页面中的HTTP API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆