jquery getJSON

// <![CDATA[
$(document).ready(
function() {
var xxx=1;
var fut;
$.getJSON("http://v.juhe.cn/weather/index?callback=?", {
"cityname" : "江津",
"dtype" : "json",
"key" : "sdfsdfsdf"<!-- juhe 的个人密匙 -->
}, function(data) {
var sb = data.reason;
if(sb!="successed!" )
$("#sspan").append(sb);
if(sb=="查询成功!")
   $("#sspan").remove();
var sk = data.result.sk;
var today = data.result.today;
var futur = data.result.future;
var ssk;
fut = "<tr><th>日期</th><th>温度</th><th>天气</th><th>风向</th></tr>";
if(today){
for (var i in futur) {
fut += "<tr><td>" + futur[i].date + ' , ' + futur[i].week + "</td><td>" +  futur[i].temperature + "</td><td>" + futur[i].weather + "</td><td>" + futur[i].wind + "</td></tr>";
}
for(var x in today)
if(today[x]!="[object Object]")
ssk+="<tr><td>"+today[x]+"</tr></td>";
$("#result_fut").html(fut);
$("#resultIndex").html(ssk);
}
});
$("#tj").click(function(){
       xxx++;
      if(xxx%2==0)
      { $("#result_fut").hide(); $("#tj").val("查看本周");}
else
   {$("#result_fut").show();$("#tj").val("只看今天");}

});
});
// ]]>

你可能感兴趣的:(jquery getJSON)