我在我的网站上做了一些非常基本的jQuery ajax的东西,我遇到了一大堆麻烦。jQuery ajax不会发出HTTPS请求
下面是相关代码:
$(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, textStatus, errorThrown) {
$("#errorbox").html(textStatus + " " + errorThrown);
}
});
});
});
加载页面时通过HTTPS,但似乎XMLHttpRequest的通过HTTP出去。
我试图将网址更改为绝对网址(https://larsendt.com/jsontest/randomdata),并且它仍然将请求发送到我的网站的HTTP版本。
当然,由于请求将转到不同的协议,所以ajax调用失败(跨域和全部)。
据报道由铬:
The page at https://larsendt.com/jsontest/ displayed insecure content from http://larsendt.com/jsontest/randomdata/?ymax=500&count=32&t=0.08111811126582325.
唯一的其他有关我能想到的信息是,我有nginx的做301重定向从http://larsendt.com到https://larsendt.com,但我看不出那会打破任何东西(我相信这是相当标准的做法)。
如果你想要一个现场演示,破损版本仍然在https://larsendt.com/jsontest。
无论如何,在此先感谢。
你介意改变你的帖子的标题,让这个查询的人不会登陆这个页面。 – brayne