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