jQuery ajax不会发出HTTPS请求

我在我的网站上做了一些非常基本的jQuery ajax东西,而且我遇到了一大堆麻烦.

这是相关的代码:

$(document).ready( function() {
    $("#getdatabutton").click( function() {
        $.ajax({
            url: "/jsontest/randomdata",type: "get",data: [{name:"ymax",value:$("#randomgraph").height()},{name:"count",value:$("#countinput").val()},{name:"t",value:Math.random()}],success: function(response,textStatus,jqXHR) {
                data = JSON.parse(response);
                updateGraph(data);
                $("#result").html(response);

                if(data["error"] == "") {
                    $("#errorbox").html("None");
                }
                else {
                    $("#errorbox").html(data["error"]);
                }
            },error: function(jqXHR,errorThrown) {
                $("#errorbox").html(textStatus + " " + errorThrown);
            }
        });
    });
});

页面通过HTTPS加载,但XMLHttpRequests似乎通过HTTP传出.

我甚至尝试将url更改为绝对URL(https://larsendt.com/jsontest/randomdata),它仍然将请求发送到我的站点的HTTP版本.

当然,由于请求是针对不同的协议,因此ajax调用失败(跨域和所有这些).

据Chrome报道:

The page at https://larsendt.com/jsontest/ displayed insecure content from http://larsendt.com/jsontest/randomdata/?ymax=500&count=32&t=0.08111811126582325.

我能想到的唯一其他相关信息是我有nginx从http://larsendt.comhttps://larsendt.com进行301重定向,但我不知道这会如何破坏任何东西(我相信这是相当标准的做法).

如果你想要一个现场演示,破碎的版本仍然在https://larsendt.com/jsontest.

无论如何,提前谢谢.

尝试修复URL,以便您的服务器不必重定向

url: "/jsontest/randomdata/" // there was a missing trailing /

// i.e.  https://larsendt.com/jsontest/randomdata?ymax=500&count=32&t=0.9604179110508643
// was going to https://larsendt.com/jsontest/randomdata/?ymax=500&count=32&t=0.9604179110508643

相关文章

文章浏览阅读3.7k次,点赞2次,收藏5次。Nginx学习笔记一、N...
文章浏览阅读1.7w次,点赞14次,收藏61次。我们在使用容器的...
文章浏览阅读1.4k次。当用户在访问网站的过程中遇到404错误时...
文章浏览阅读2.7k次。docker 和 docker-compose 部署 nginx+...
文章浏览阅读1.3k次。5:再次启动nginx,可以正常启动,可以...
文章浏览阅读3.1w次,点赞105次,收藏182次。高性能:Nginx ...