json 値をスクリプトにバインドし、html での出力が必要な方法。天気のデータと画像を取得しようとしていますが、解決策はありません。助けて
ここにjqueryのサンプルがあります
$(function(){
$.getJSON("http://query.yahooapis.com/v1/public/yql", {
q: "select * from json where url=\"http://api.wunderground.com/api/91bbc8aab3ab1f34/geolookup/conditions/q/IN/Chennai.json\"",
format: "json"
}, function(data) {
var $content = $("#content")
if (data.query.results) {
$content.text(JSON.stringify(data.query.results));
} else {
$content.text('no such code: ' + code);
}
});
});
html のコード
<script type="text/javascript" src="http://ajax.cdnjs.com/ajax/libs/json2/20110223/json2.js"></script>
コンテンツは div で、アイコンはイメージ タグです
<div id="content">
<img id="weather_icon" />
アプリケーションを実行すると、データだけが取得されます。API からの天気画像とデータが必要です。助けてください