jQuery ajax不会发出HTTPS请求

weixin_38065414 weixin_38065414 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
我在我的网站上做了一些非常基本的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, textStatus, 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.com到https://larsendt.com进行301重定向,但我不知道这会如何破坏任何东西(我相信这是相当标准的做法). 如果你想要一个现场演示,破碎的版本仍然在https://larsendt.com/jsontest. 无论如何,提前谢谢.
...全文
评论 1
收藏 已收藏
分享
返回顶部