我有一个站点托管在https://
上,我想从该站点获取显示共享属性的网站数据。返回数据的网址是:无法使用XMLHttpRequest()从http站点检索数据https()
http://ir1.euroinvestor.com/asp/ir/xmlirmultiiso2.aspx?companyid=281191
我已经发展到获取数据的代码如下:
function GetSharesUpdate(){
// makeing AJAX calls to the web service for getting the share update
var xhr = new XMLHttpRequest(); // Set up xhr request
xhr.open("GET", "http://ir1.euroinvestor.com/asp/ir/xmlirmultiiso2.aspx?companyid=281191", true); // Open the request
xhr.responseType = ""; // Set the type of response expected
xhr.send();
// Asynchronously wait for the data to return
xhr.onreadystatechange = function() {
if (xhr.readyState == xhr.DONE) {
var tempoutput = xhr.responseXML;
alert(tempoutput);
}
}
// Report errors if they happen
xhr.addEventListener("error", function (e) {
console.error("Error: " + e + " Could not load url.");
}, false);
}
我收到的声明xhr.send();
这是错误如下:
混合内容:在 'https://[SiteUrl]' 加载页面通过HTTPS, 但要求一个insecu re XMLHttpRequest端点 'http://ir1.euroinvestor.com/asp/ir/xmlirmultiiso2.aspx?companyid=281191'。 此请求已被阻止;内容必须通过HTTPS提供。
如果我更改URL,以https
即
https://ir1.euroinvestor.com/asp/ir/xmlirmultiiso2.aspx?companyid=281191
然后xhr.send();
是没有任何错误执行,但我得到xhr.responseXML
空。
我应该怎样改变我的代码才能使它工作?
你的第二个url中有四个斜线('/')。那是对的吗? – FrankerZ
感谢您的关注。添加帖子时出现输入错误。 –
它执行没有任何错误?这不是当我运行它:* VM155 nizaqapusu.js:6 GET https://ir1.euroinvestor.com/asp/ir/xmlirmultiiso2.aspx?companyid=281191net :: ERR_INSECURE_RESPONSE *,当我访问的网址铬抱怨SSL证书用于不同的主机名。 – Quentin