【问题标题】:Mixed Content Issue $http.get AngularJS混合内容问题 $http.get AngularJS
【发布时间】:2015-10-31 01:03:53
【问题描述】:

我有一个在 HTTPS 协议上运行的应用程序。我编写了一个 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.get 服务中将http://gainsight.0x10.info/api/image?page_no=0 更改为https://gainsight.0x10.info/api/image?page_no=0,但遗憾的是不可用。

任何帮助.. 非常感谢

【问题讨论】:

    标签: javascript ajax angularjs http mixed-content


    【解决方案1】:

    删除协议!!

    不要使用https://...,而是使用//...

    希望它有效:)

    Reference

    【讨论】:

    • 它只是将“https”添加到您的网址(或 http,关于您当前的协议)
    【解决方案2】:

    即使您能够调用 http 端点,您也将无法加载资源,因为它位于不同的域中并且您有跨域问题(除非您使用 jsonp 或 cors 修复该问题)

    http://www.d-mueller.de/blog/cross-domain-ajax-guide/

    【讨论】:

      猜你喜欢
      • 2017-08-06
      • 2018-02-23
      • 2016-09-04
      • 2015-08-13
      • 2017-09-27
      • 1970-01-01
      • 1970-01-01
      • 2019-06-19
      • 2011-06-19
      相关资源
      最近更新 更多