jQuery/JavaScript 및 ajax로 처음 작업했으며 날씨 기온 API를 사용하여 웹 사이트에서 날씨 정보를 표시하려고합니다. Google 클라우드에서 호스팅되는 페이지jQuery Ajax Json이 Google Cloud 서비스와 함께 작동하지 않음 HTML 파일에서 구문 분석
날씨 지하 코드 예제를 읽었으며 그 코드로 익숙해지기 때문에 노력하고 있습니다.하지만 코드를 익숙하게 보이려고 노력하고 있습니다.하지만 앞으로 나아갈 수 있도록 노력하고 있습니다. 비슷한 코드 질문을했지만 다른 곳에서는 아직 얻을 수없는 다른 스택 오버 플로우를 살펴 보았습니다. 중복에 대해 사과하지만 그것이 작동하지 않는 이유가 확실하지 않습니다.
모든 것이 의미가있는 것처럼 보입니다. 그러나 페이지가로드 될 때 HTML이 "경고"한다고 가정 할 때 나는 아무것도 얻지 못합니다. 비록 내가 바보 같은 일을하고있다 할지라도 나는 약간의 의견을 진심으로 감사 할 것입니다.
다음은 JavaScript와 HTML이 혼합 된 HTML 파일입니다.
<!DOCTYPE html>
<html>
<head>
<title>Hello, The Cloud!</title>
<link rel="stylesheet" type="text/css" href="/static/style.css">
</head>
<body>
<h1>Hello, The Cloud!</h1>
<p> Lets Check the Weather! </p>
</body>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
<script type="text/javascript">
jQuery(document).ready(function($) {
$.ajax({
url : "http://api.wunderground.com/api/47acb7d74302f585/geolookup/conditions/q/IA/Cedar_Rapids.json",
dataType : "jsonp",
success : function(parsed_json) {
var location = parsed_json['location']['city'];
var temp_f = parsed_json['current_observation']['temp_f'];
alert("Current temperature in " + location + " is: " + temp_f);
}
});
});
</script>
</html>
간단한 CSS 파일이 아래에 나와 있습니다.
h1 {
color: #000000;
text-align: center;
font-size: 60px;
text-decoration: underline;
}
body {
background-color: LavenderBlush;
font-size: 20px;
}
div {
background-color: lightgrey;
color: #FF0000;
id: "clockbox";
font-size: 20px;
font-family: "Times New Roman", Times, Serif;
width: 420px;
padding: 10px;
border: 5px solid gray;
margin: 0;
}
.alert {
padding: 20px;
background-color: #f44336; /* Red */
color: white;
margin-bottom: 15px;
}
의견을 보내 주셔서 감사합니다.
이 문제는 당신이 당신의<body>
태그 내부
<script>
태그를하지 않아도 당신에게
글쎄, 스크립트 전에'body'를 닫았습니까? – adeneo
그렇지 않으면 괜찮아 보입니다 -> http://jsfiddle.net/adeneo/pw8fgfds/1/ – adeneo
콘솔을 확인 했습니까? HTTPS 문제가 있다고 추측하면 Google Cloud는 HTTPS에서 작동하지만 HTTP를 통해 Underground의 API를 요청하고 있습니다. – yuriy636