0
私はAPIを学習しており、プロセスの初心者です。どんな助けも貴重です。HTMLでAPIレスポンスを表示
私はXMLレスポンスとして探しているデータを取得して、それをconsole.loggedにクロムで記録しました。
200
OK
#document
all of the XML is contained in here that I need to access and display
<!doctype html>
<html>
<head>
<script>
window.onload = function() {
var xhr = new XMLHttpRequest();
xhr.open("GET","http://api.openweathermap.org/data/2.5/weather?lat=35&lon=139&mode=xml&APPID=92cc96ecfe265f251d814b66592a7848",false);
xhr.send();
console.log(xhr.status);
console.log(xhr.statusText);
console.log(xhr.responseXML);
var response = xhr.responseXML;
var xmlString = (new XMLSerializer()).serializeToString(response);
if(xhr.status == 200){
document.getElementById("document").innerHTML = xmlString;
}
}
</script>
<meta charset="UTF-8">
<title>Weather API Test</title>
</head>
<body id="body">
<div id="document"></div>
</body>
</html>
私は週末全体を検索しましたが、私が理解できる解決策です。
で他人を助けるために、以下の投稿はなぜダウン投票? – anthonytherockjohnson