javascript - 混合内容问题 $http.get AngularJS

标签 javascript ajax angularjs http mixed-content

我有一个在 HTTPS 协议(protocol)上运行的应用程序。我编写了一个 Angular 函数来使用 $http 服务获取数据。

factory.loadImages = function(callback){

        $http.get("http://gainsight.0x10.info/api/image?page_no=0")
             .success(function(data){

                callback(data);

            }).error(function(status,error){

                console.log(status);

            });
    };

我收到以下混合内容错误:

Mixed Content: The page at 'https://www.hackerearth.com/gainsight-ui-development-hiring-challenge-1/problems/30146b3bf6954bba9752bd5599b3c8aa/' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://gainsight.0x10.info/api/image?page_no=0'. This content should also be served over HTTPS.

现在我尝试更改 http://gainsight.0x10.info/api/image?page_no=0https://gainsight.0x10.info/api/image?page_no=0在我的 $http.get 服务中,不幸的是它不可用。

任何帮助..非常感谢

最佳答案

删除协议(protocol)!!

不要使用 https://...,只需使用 //...

希望它有用:)

Reference

关于javascript - 混合内容问题 $http.get AngularJS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31880201/

相关文章:

javascript - 如何从定义函数而不是调用对象访问变量状态

javascript - 在 Javascript 文件中加载并执行 jQuery

javascript - jQuery 动态表单,且 PHP $_FILES 为空

javascript - Rails Ajax 远程 Javascript

javascript - 无法将参数从ajax传递到php

javascript - 对象的顺序已更改

javascript - 如何搜索 li 包含文本值?

javascript - 为什么我在使用 push() 时总是在数组中获取数组?

javascript - ionic 框架 - Angular html 包含

angularjs - 使用非 Angular 登录进行 Angular e2e 测试