混合内容:“ 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 (将#修改为@)