私はhttps://
にホストされているサイトで、共有のプロパティを示すサイトからデータを取得したいと考えています。データを返すURLは次のとおりです。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を要求されましたXMLHttpRequestエンドポイント 'http://ir1.euroinvestor.com/asp/ir/xmlirmultiiso2.aspx?companyid=281191'。 このリクエストはブロックされました。 HTTPS経由でコンテンツを配信する必要があります。
私はhttps
にURLを変更した場合、すなわち
https://ir1.euroinvestor.com/asp/ir/xmlirmultiiso2.aspx?companyid=281191
その後、xhr.send();
がエラーなしで実行されますが、私はxhr.responseXML
ヌルを取得しています。
コードを変更して機能させるにはどうすればよいですか?
あなたの2番目のURLの4個のスラッシュ( '/')があります。あれは正しいですか? – FrankerZ
注目をいただきありがとうございます。投稿を追加している間に入力ミスがありました。 –
エラーなく実行されますか? * VM155 nizaqapusu.js:6 GET https://ir1.euroinvestor.com/asp/ir/xmlirmultiiso2.aspx?companyid=281191 net :: ERR_INSECURE_RESPONSE *と私がChromeのURLにアクセスしたときSSL証明書が別のホスト名用であると不平を言う。 – Quentin