微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

混合内容:“ https:// localhost:44387 / Home / Index”上的页面已通过HTTPS加载,但请求了不安全的XMLHttpRequest端点

如何解决混合内容:“ https:// localhost:44387 / Home / Index”上的页面已通过HTTPS加载,但请求了不安全的XMLHttpRequest端点

我一直在尝试从本地主机(为https设置了身份)向通过HTTP的服务器发出AJAX请求。每当我从浏览器收到错误消息时,都会说它已被阻止,因为通话中存在“混合内容”。 我如何避免这种错误?有时在浏览器中,我可以看到所需的JSON响应,但由于错误,它从未进入页面

这是我单击按钮以请求数据时的代码

$(document).ready(function () {
var gallery = null;

$("#getSubscriptionWorkflows").click(function () {
    gallery = new gallery($("#apiLocation").val().trim(),$("#apiKey").val().trim(),$("#apiSecret").val().trim());
    gallery.getSubscriptionWorkflows(function (workflows) {
        var listStr = "";
        var len = workflows.length;
        if (len === 0) {
            listStr = "There are no workflows in the subscription associated with the given api key";
        }
        for (var i = 0; i < len; i++) {
            listStr += "<li>" + workflows[i].MetaInfo.name + " - " + workflows[i].id + "</li>";
        }
        $("#workflowList").html(listStr);
    },function (response) {
        $("#workflowList").html(response.responseJSON && response.responseJSON.message || response.statusText);
    });
});
});

这是API代码

gallery = function(apiLocation,apiKey,apiSecret) {
this.apiKey = apiKey;
this.apiSecret = apiSecret;
this.apiLocation = apiLocation;

this.getSubscriptionWorkflows = function (success,error){
    var type = "GET",url = this.apiLocation + "/workflows/subscription/",params = buildOauthParams(this.apiKey),//add any user parameters before generating the signature
        signature = generateSignature(type,url,params,this.apiSecret);
    $.extend(params,{oauth_signature: signature});
    $.ajax({
        type: type,url: url,data: params,success: success,error: error
    });
};

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。