我在我的網站上做了一些非常基本的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