更新时间:2022-06-24 15:10:33
只需更改你的url变量中 http://
到 //
,所以当页面加载http时,ajax请求将使用http协议,如果加载https,浏览器将ajax请求协议设置为https。即,您的代码应如下所示:
Just change the http://
in your url variable to //
, so when the page is loaded with http, the ajax request would use the http protocol, if loaded with https, the ajax request protocol would be set by the browser to https. i.e, your code should look like:
$.ajax({
url : "//example.com/non-https",
..
..