混合内容:网址'网址'是通过HTTPS加载的AngularJS

时间:2016-05-28 21:05:14

标签: angularjs http http-status-codes duckduckgo-api

我正在创建一个应用,我想将$ http.get请求发送到duckduck的API,但是他们的请求是通过HTTP完成的。看到我的网站是HTTP会收到以下错误:

angular.js:11756 Mixed Content: 
The page at 'URL' was loaded over HTTPS, 
but requested an insecure XMLHttpRequest endpoint 'http://api.duckduckgo.com/'. 
This request has been blocked; the content must be served over HTTPS.

当我将s添加到我的请求中时,我显然得到以下内容(看到CORS没有设置):

XMLHttpRequest cannot load:
https://api.duckduckgo.com/?q=Undulated%20Tinamou&format=json&pretty=1. 
Response to preflight request doesn't pass access control check: 
No 'Access-Control-Allow-Origin' header is present on the requested resource. 
Origin 'https://URL' is therefore not allowed access. The response had HTTP status code 405.

我的问题:有没有让我获得json并绕过上述两个中的一个?

编辑1:

$http.get('https://api.duckduckgo.com/?q=' + birdname + '&format=json&callback=jsonp&pretty=1').then(function(res){
            console.log(res.data);
        });

我也尝试了以下内容:

$http.jsonp('https://api.duckduckgo.com/?q=' + birdname + '&format=json&callback=jsonp&pretty=1').then(function(res){
                console.log(res.data);
            });

对于第二个,我收到以下错误:

Uncaught ReferenceError: json is not defined

0 个答案:

没有答案