你好,歡迎來到IOS教程網

 Ios教程網 >> IOS編程開發 >> IOS開發綜合 >> iOS學習筆記29—天氣JSON接口

iOS學習筆記29—天氣JSON接口

編輯:IOS開發綜合

想寫個天氣的應用,在網上找了一圈都沒找到有關 JSONP 的接口,只有中國天氣網的 JSON 接口,這就簡單,直接用 SAE 做代理,將數據處理為 JSONP 的形式返回就行了,順便分析了中國天氣網的省市區三級聯動的數據,這樣就直接可以做天氣應用了。


說說我的接口的用法吧,直接 get 請求,
參數有三個 。

get 參數,獲取操作
可以取值 "province","city","town","weather","weathern";分別是獲取省 (直轄市) 的列表,根據省 ID 獲取市的列表,根據省市的 ID 獲取區縣列表,根據省市區 ID 獲取天氣預報,根據省市區 ID 獲取實時天氣。
citycode 參數
就是操作中需要的 ID,獲取省列表就可以不需要了
callback 參數
就是 JSONP 的 callback 啦。
具體用法看看我的 Demo 吧,demo 地址:天氣接口 JSONP 示例,

 

 [javascript]
<SPAN style="FONT-SIZE: 14px"><SPAN style="COLOR: rgb(0,0,102)"><STRONG>var</STRONG></SPAN> baseUrl <SPAN style="COLOR: #339933">=</SPAN> <SPAN style="COLOR: #3366cc">"http://demo.alphatr.com/weather/info.php"</SPAN><SPAN style="COLOR: #339933">;</SPAN> 
  
<SPAN style="COLOR: #006600">// 將獲取的省市區列表 JSON 格式轉換為 HTML 字符串</SPAN>  
<SPAN style="COLOR: #000066"><STRONG>var</STRONG></SPAN> appendData <SPAN style="COLOR: #339933">=</SPAN> <SPAN style="COLOR: #000066"><STRONG>function</STRONG></SPAN><SPAN style="COLOR: #009900">(</SPAN> data <SPAN style="COLOR: #339933">,</SPAN> el <SPAN style="COLOR: #009900">)</SPAN> <SPAN style="COLOR: #009900">{</SPAN> 
    <SPAN style="COLOR: #000066"><STRONG>var</STRONG></SPAN> list <SPAN style="COLOR: #339933">=</SPAN> <SPAN style="COLOR: #009900">[</SPAN><SPAN style="COLOR: #009900">]</SPAN><SPAN style="COLOR: #339933">;</SPAN> 
    $.<SPAN style="COLOR: #660066">each</SPAN><SPAN style="COLOR: #009900">(</SPAN>data<SPAN style="COLOR: #339933">,</SPAN> <SPAN style="COLOR: #000066"><STRONG>function</STRONG></SPAN><SPAN style="COLOR: #009900">(</SPAN> key<SPAN style="COLOR: #339933">,</SPAN> val <SPAN style="COLOR: #009900">)</SPAN><SPAN style="COLOR: #009900">{</SPAN> 
        <SPAN style="COLOR: #006600">// console.log(key);</SPAN>  
        list.<SPAN style="COLOR: #660066">push</SPAN><SPAN style="COLOR: #009900">(</SPAN><SPAN style="COLOR: #3366cc">'<option value="'</SPAN> <SPAN style="COLOR: #339933">+</SPAN> key <SPAN style="COLOR: #339933">+</SPAN> <SPAN style="COLOR: #3366cc">'">'</SPAN> <SPAN style="COLOR: #339933">+</SPAN> val <SPAN style="COLOR: #339933">+</SPAN> <SPAN style="COLOR: #3366cc">'</option>'</SPAN><SPAN style="COLOR: #009900">)</SPAN><SPAN style="COLOR: #339933">;</SPAN> 
    <SPAN style="COLOR: #009900">}</SPAN><SPAN style="COLOR: #009900">)</SPAN> 
    $<SPAN style="COLOR: #009900">(</SPAN>el<SPAN style="COLOR: #009900">)</SPAN>.<SPAN style="COLOR: #660066">html</SPAN><SPAN style="COLOR: #009900">(</SPAN>list.<SPAN style="COLOR: #660066">join</SPAN><SPAN style="COLOR: #009900">(</SPAN><SPAN style="COLOR: #3366cc">''</SPAN><SPAN style="COLOR: #009900">)</SPAN><SPAN style="COLOR: #009900">)</SPAN><SPAN style="COLOR: #339933">;</SPAN> 
<SPAN style="COLOR: #009900">}</SPAN> 
<SPAN style="COLOR: #006600">/* 三級聯動 */</SPAN> 
<SPAN style="COLOR: #006600">// 獲取省列表</SPAN>  
$.<SPAN style="COLOR: #660066">getJSON</SPAN><SPAN style="COLOR: #009900">(</SPAN> baseUrl <SPAN style="COLOR: #339933">+</SPAN> <SPAN style="COLOR: #3366cc">"?get=province&callback=?"</SPAN> <SPAN style="COLOR: #339933">,</SPAN> <SPAN style="COLOR: #000066"><STRONG>function</STRONG></SPAN> <SPAN style="COLOR: #009900">(</SPAN>data<SPAN style="COLOR: #009900">)</SPAN> <SPAN style="COLOR: #009900">{</SPAN> 
    appendData<SPAN style="COLOR: #009900">(</SPAN> data <SPAN style="COLOR: #339933">,</SPAN> <SPAN style="COLOR: #3366cc">"#province"</SPAN> <SPAN style="COLOR: #009900">)</SPAN><SPAN style="COLOR: #339933">;</SPAN> 
    <SPAN style="COLOR: #000066"><STRONG>var</STRONG></SPAN> provCode <SPAN style="COLOR: #339933">=</SPAN> $<SPAN style="COLOR: #009900">(</SPAN><SPAN style="COLOR: #3366cc">"#province"</SPAN><SPAN style="COLOR: #009900">)</SPAN>.<SPAN style="COLOR: #660066">val</SPAN><SPAN style="COLOR: #009900">(</SPAN><SPAN style="COLOR: #009900">)</SPAN><SPAN style="COLOR: #339933">;</SPAN> <SPAN style="COLOR: #006600">// 省 ID</SPAN>  
    <SPAN style="COLOR: #006600">// 根據省 ID 獲取市列表</SPAN>  
    $.<SPAN style="COLOR: #660066">getJSON</SPAN><SPAN style="COLOR: #009900">(</SPAN> baseUrl <SPAN style="COLOR: #339933">+</SPAN> <SPAN style="COLOR: #3366cc">"?get=city&citycode="</SPAN> <SPAN style="COLOR: #339933">+</SPAN> provCode <SPAN style="COLOR: #339933">+</SPAN> <SPAN style="COLOR: #3366cc">"&callback=?"</SPAN> <SPAN style="COLOR: #339933">,</SPAN> <SPAN style="COLOR: #000066"><STRONG>function</STRONG></SPAN> <SPAN style="COLOR: #009900">(</SPAN>data<SPAN style="COLOR: #009900">)</SPAN> <SPAN style="COLOR: #009900">{</SPAN> 
        appendData<SPAN style="COLOR: #009900">(</SPAN> data <SPAN style="COLOR: #339933">,</SPAN> <SPAN style="COLOR: #3366cc">"#city"</SPAN> <SPAN style="COLOR: #009900">)</SPAN><SPAN style="COLOR: #339933">;</SPAN> 
        <SPAN style="COLOR: #000066"><STRONG>var</STRONG></SPAN> cityCode <SPAN style="COLOR: #339933">=</SPAN> $<SPAN style="COLOR: #009900">(</SPAN><SPAN style="COLOR: #3366cc">"#city"</SPAN><SPAN style="COLOR: #009900">)</SPAN>.<SPAN style="COLOR: #660066">val</SPAN><SPAN style="COLOR: #009900">(</SPAN><SPAN style="COLOR: #009900">)</SPAN><SPAN style="COLOR: #339933">;</SPAN> <SPAN style="COLOR: #006600">// 市 ID</SPAN>  
        <SPAN style="COLOR: #006600">// 獲取區 列表</SPAN>  
        $.<SPAN style="COLOR: #660066">getJSON</SPAN><SPAN style="COLOR: #009900">(</SPAN> baseUrl <SPAN style="COLOR: #339933">+</SPAN> <SPAN style="COLOR: #3366cc">"?get=town&citycode="</SPAN> <SPAN style="COLOR: #339933">+</SPAN> provCode <SPAN style="COLOR: #339933">+</SPAN> cityCode <SPAN style="COLOR: #339933">+</SPAN> <SPAN style="COLOR: #3366cc">"&callback=?"</SPAN> <SPAN style="COLOR: #339933">,</SPAN> <SPAN style="COLOR: #000066"><STRONG>function</STRONG></SPAN> <SPAN style="COLOR: #009900">(</SPAN>data<SPAN style="COLOR: #009900">)</SPAN> <SPAN style="COLOR: #009900">{</SPAN> 
            appendData<SPAN style="COLOR: #009900">(</SPAN> data <SPAN style="COLOR: #339933">,</SPAN> <SPAN style="COLOR: #3366cc">"#town"</SPAN> <SPAN style="COLOR: #009900">)</SPAN><SPAN style="COLOR: #339933">;</SPAN> 
        <SPAN style="COLOR: #009900">}</SPAN><SPAN style="COLOR: #009900">)</SPAN> 
    <SPAN style="COLOR: #009900">}</SPAN><SPAN style="COLOR: #009900">)</SPAN> 
<SPAN style="COLOR: #009900">}</SPAN><SPAN style="COLOR: #009900">)</SPAN> 
  
<SPAN style="COLOR: #006600">/* 相應值的改變 */</SPAN> 
$<SPAN style="COLOR: #009900">(</SPAN><SPAN style="COLOR: #3366cc">"#province"</SPAN><SPAN style="COLOR: #009900">)</SPAN>.<SPAN style="COLOR: #660066">bind</SPAN><SPAN style="COLOR: #009900">(</SPAN> <SPAN style="COLOR: #3366cc">"change"</SPAN> <SPAN style="COLOR: #339933">,</SPAN> <SPAN style="COLOR: #000066"><STRONG>function</STRONG></SPAN><SPAN style="COLOR: #009900">(</SPAN><SPAN style="COLOR: #009900">)</SPAN><SPAN style="COLOR: #009900">{</SPAN> 
    <SPAN style="COLOR: #000066"><STRONG>var</STRONG></SPAN> provCode <SPAN style="COLOR: #339933">=</SPAN> $<SPAN style="COLOR: #009900">(</SPAN><SPAN style="COLOR: #3366cc">"#province"</SPAN><SPAN style="COLOR: #009900">)</SPAN>.<SPAN style="COLOR: #660066">val</SPAN><SPAN style="COLOR: #009900">(</SPAN><SPAN style="COLOR: #009900">)</SPAN><SPAN style="COLOR: #339933">;</SPAN> 
    $.<SPAN style="COLOR: #660066">getJSON</SPAN><SPAN style="COLOR: #009900">(</SPAN> baseUrl <SPAN style="COLOR: #339933">+</SPAN> <SPAN style="COLOR: #3366cc">"?get=city&citycode="</SPAN> <SPAN style="COLOR: #339933">+</SPAN> provCode <SPAN style="COLOR: #339933">+</SPAN> <SPAN style="COLOR: #3366cc">"&callback=?"</SPAN> <SPAN style="COLOR: #339933">,</SPAN> <SPAN style="COLOR: #000066"><STRONG>function</STRONG></SPAN> <SPAN style="COLOR: #009900">(</SPAN>data<SPAN style="COLOR: #009900">)</SPAN> <SPAN style="COLOR: #009900">{</SPAN> 
        appendData<SPAN style="COLOR: #009900">(</SPAN> data <SPAN style="COLOR: #339933">,</SPAN> <SPAN style="COLOR: #3366cc">"#city"</SPAN> <SPAN style="COLOR: #009900">)</SPAN><SPAN style="COLOR: #339933">;</SPAN> 
        <SPAN style="COLOR: #000066"><STRONG>var</STRONG></SPAN> cityCode <SPAN style="COLOR: #339933">=</SPAN> $<SPAN style="COLOR: #009900">(</SPAN><SPAN style="COLOR: #3366cc">"#city"</SPAN><SPAN style="COLOR: #009900">)</SPAN>.<SPAN style="COLOR: #660066">val</SPAN><SPAN style="COLOR: #009900">(</SPAN><SPAN style="COLOR: #009900">)</SPAN><SPAN style="COLOR: #339933">;</SPAN> 
        $.<SPAN style="COLOR: #660066">getJSON</SPAN><SPAN style="COLOR: #009900">(</SPAN> baseUrl <SPAN style="COLOR: #339933">+</SPAN> <SPAN style="COLOR: #3366cc">"?get=town&citycode="</SPAN> <SPAN style="COLOR: #339933">+</SPAN> provCode <SPAN style="COLOR: #339933">+</SPAN> cityCode <SPAN style="COLOR: #339933">+</SPAN> <SPAN style="COLOR: #3366cc">"&callback=?"</SPAN> <SPAN style="COLOR: #339933">,</SPAN> <SPAN style="COLOR: #000066"><STRONG>function</STRONG></SPAN> <SPAN style="COLOR: #009900">(</SPAN>data<SPAN style="COLOR: #009900">)</SPAN> <SPAN style="COLOR: #009900">{</SPAN> 
            appendData<SPAN style="COLOR: #009900">(</SPAN> data <SPAN style="COLOR: #339933">,</SPAN> <SPAN style="COLOR: #3366cc">"#town"</SPAN> <SPAN style="COLOR: #009900">)</SPAN><SPAN style="COLOR: #339933">;</SPAN> 
        <SPAN style="COLOR: #009900">}</SPAN><SPAN style="COLOR: #009900">)</SPAN> 
    <SPAN style="COLOR: #009900">}</SPAN><SPAN style="COLOR: #009900">)</SPAN> 
<SPAN style="COLOR: #009900">}</SPAN><SPAN style="COLOR: #009900">)</SPAN> 
  
$<SPAN style="COLOR: #009900">(</SPAN><SPAN style="COLOR: #3366cc">"#city"</SPAN><SPAN style="COLOR: #009900">)</SPAN>.<SPAN style="COLOR: #660066">bind</SPAN><SPAN style="COLOR: #009900">(</SPAN> <SPAN style="COLOR: #3366cc">"change"</SPAN> <SPAN style="COLOR: #339933">,</SPAN> <SPAN style="COLOR: #000066"><STRONG>function</STRONG></SPAN><SPAN style="COLOR: #009900">(</SPAN><SPAN style="COLOR: #009900">)</SPAN><SPAN style="COLOR: #009900">{</SPAN> 
    <SPAN style="COLOR: #000066"><STRONG>var</STRONG></SPAN> provCode <SPAN style="COLOR: #339933">=</SPAN> $<SPAN style="COLOR: #009900">(</SPAN><SPAN style="COLOR: #3366cc">"#province"</SPAN><SPAN style="COLOR: #009900">)</SPAN>.<SPAN style="COLOR: #660066">val</SPAN><SPAN style="COLOR: #009900">(</SPAN><SPAN style="COLOR: #009900">)</SPAN><SPAN style="COLOR: #339933">;</SPAN> 
    <SPAN style="COLOR: #000066"><STRONG>var</STRONG></SPAN> cityCode <SPAN style="COLOR: #339933">=</SPAN> $<SPAN style="COLOR: #009900">(</SPAN><SPAN style="COLOR: #3366cc">"#city"</SPAN><SPAN style="COLOR: #009900">)</SPAN>.<SPAN style="COLOR: #660066">val</SPAN><SPAN style="COLOR: #009900">(</SPAN><SPAN style="COLOR: #009900">)</SPAN><SPAN style="COLOR: #339933">;</SPAN> 
    $.<SPAN style="COLOR: #660066">getJSON</SPAN><SPAN style="COLOR: #009900">(</SPAN> baseUrl <SPAN style="COLOR: #339933">+</SPAN> <SPAN style="COLOR: #3366cc">"?get=town&citycode="</SPAN> <SPAN style="COLOR: #339933">+</SPAN> provCode <SPAN style="COLOR: #339933">+</SPAN> cityCode <SPAN style="COLOR: #339933">+</SPAN> <SPAN style="COLOR: #3366cc">"&callback=?"</SPAN> <SPAN style="COLOR: #339933">,</SPAN> <SPAN style="COLOR: #000066"><STRONG>function</STRONG></SPAN> <SPAN style="COLOR: #009900">(</SPAN>data<SPAN style="COLOR: #009900">)</SPAN> <SPAN style="COLOR: #009900">{</SPAN> 
        appendData<SPAN style="COLOR: #009900">(</SPAN> data <SPAN style="COLOR: #339933">,</SPAN> <SPAN style="COLOR: #3366cc">"#town"</SPAN> <SPAN style="COLOR: #009900">)</SPAN><SPAN style="COLOR: #339933">;</SPAN> 
    <SPAN style="COLOR: #009900">}</SPAN><SPAN style="COLOR: #009900">)</SPAN> 
<SPAN style="COLOR: #009900">}</SPAN><SPAN style="COLOR: #009900">)</SPAN> 
  
<SPAN style="COLOR: #006600">// 響應獲取按鈕</SPAN>  
$<SPAN style="COLOR: #009900">(</SPAN><SPAN style="COLOR: #3366cc">"#btn"</SPAN><SPAN style="COLOR: #009900">)</SPAN>.<SPAN style="COLOR: #660066">bind</SPAN><SPAN style="COLOR: #009900">(</SPAN> <SPAN style="COLOR: #3366cc">"click"</SPAN> <SPAN style="COLOR: #339933">,</SPAN> <SPAN style="COLOR: #000066"><STRONG>function</STRONG></SPAN><SPAN style="COLOR: #009900">(</SPAN><SPAN style="COLOR: #009900">)</SPAN> <SPAN style="COLOR: #009900">{</SPAN> 
    <SPAN style="COLOR: #000066"><STRONG>var</STRONG></SPAN> code <SPAN style="COLOR: #339933">=</SPAN> $<SPAN style="COLOR: #009900">(</SPAN><SPAN style="COLOR: #3366cc">"#province"</SPAN><SPAN style="COLOR: #009900">)</SPAN>.<SPAN style="COLOR: #660066">val</SPAN><SPAN style="COLOR: #009900">(</SPAN><SPAN style="COLOR: #009900">)</SPAN><SPAN style="COLOR: #339933">;</SPAN> 
    <SPAN style="COLOR: #000066"><STRONG>if</STRONG></SPAN><SPAN style="COLOR: #009900">(</SPAN> $<SPAN style="COLOR: #009900">(</SPAN><SPAN style="COLOR: #3366cc">"#city"</SPAN><SPAN style="COLOR: #009900">)</SPAN>.<SPAN style="COLOR: #660066">val</SPAN><SPAN style="COLOR: #009900">(</SPAN><SPAN style="COLOR: #009900">)</SPAN> <SPAN style="COLOR: #339933">==</SPAN> <SPAN style="COLOR: #3366cc">"00"</SPAN> <SPAN style="COLOR: #009900">)</SPAN> <SPAN style="COLOR: #009900">{</SPAN> 
        code <SPAN style="COLOR: #339933">+=</SPAN> $<SPAN style="COLOR: #009900">(</SPAN><SPAN style="COLOR: #3366cc">"#town"</SPAN><SPAN style="COLOR: #009900">)</SPAN>.<SPAN style="COLOR: #660066">val</SPAN><SPAN style="COLOR: #009900">(</SPAN><SPAN style="COLOR: #009900">)</SPAN><SPAN style="COLOR: #339933">;</SPAN> 
        code <SPAN style="COLOR: #339933">+=</SPAN> $<SPAN style="COLOR: #009900">(</SPAN><SPAN style="COLOR: #3366cc">"#city"</SPAN><SPAN style="COLOR: #009900">)</SPAN>.<SPAN style="COLOR: #660066">val</SPAN><SPAN style="COLOR: #009900">(</SPAN><SPAN style="COLOR: #009900">)</SPAN><SPAN style="COLOR: #339933">;</SPAN> 
    <SPAN style="COLOR: #009900">}</SPAN> <SPAN style="COLOR: #000066"><STRONG>else</STRONG></SPAN> <SPAN style="COLOR: #009900">{</SPAN> 
        code <SPAN style="COLOR: #339933">+=</SPAN> $<SPAN style="COLOR: #009900">(</SPAN><SPAN style="COLOR: #3366cc">"#city"</SPAN><SPAN style="COLOR: #009900">)</SPAN>.<SPAN style="COLOR: #660066">val</SPAN><SPAN style="COLOR: #009900">(</SPAN><SPAN style="COLOR: #009900">)</SPAN><SPAN style="COLOR: #339933">;</SPAN> 
        code <SPAN style="COLOR: #339933">+=</SPAN> $<SPAN style="COLOR: #009900">(</SPAN><SPAN style="COLOR: #3366cc">"#town"</SPAN><SPAN style="COLOR: #009900">)</SPAN>.<SPAN style="COLOR: #660066">val</SPAN><SPAN style="COLOR: #009900">(</SPAN><SPAN style="COLOR: #009900">)</SPAN><SPAN style="COLOR: #339933">;</SPAN> 
    <SPAN style="COLOR: #009900">}</SPAN> 
    console.<SPAN style="COLOR: #660066">log</SPAN><SPAN style="COLOR: #009900">(</SPAN>code<SPAN style="COLOR: #009900">)</SPAN><SPAN style="COLOR: #339933">;</SPAN> 
    <SPAN style="COLOR: #006600">// 獲取天氣數據</SPAN>  
    $.<SPAN style="COLOR: #660066">getJSON</SPAN><SPAN style="COLOR: #009900">(</SPAN> baseUrl <SPAN style="COLOR: #339933">+</SPAN> <SPAN style="COLOR: #3366cc">"?get=weather&citycode="</SPAN> <SPAN style="COLOR: #339933">+</SPAN> code <SPAN style="COLOR: #339933">+</SPAN> <SPAN style="COLOR: #3366cc">"&callback=?"</SPAN> <SPAN style="COLOR: #339933">,</SPAN> <SPAN style="COLOR: #000066"><STRONG>function</STRONG></SPAN> <SPAN style="COLOR: #009900">(</SPAN>data<SPAN style="COLOR: #009900">)</SPAN> <SPAN style="COLOR: #009900">{</SPAN> 
        console.<SPAN style="COLOR: #660066">log</SPAN><SPAN style="COLOR: #009900">(</SPAN>data<SPAN style="COLOR: #009900">)</SPAN><SPAN style="COLOR: #339933">;</SPAN> 
        <SPAN style="COLOR: #000066"><STRONG>var</STRONG></SPAN> info <SPAN style="COLOR: #339933">=</SPAN> <SPAN style="COLOR: #009900">[</SPAN><SPAN style="COLOR: #009900">]</SPAN><SPAN style="COLOR: #339933">;</SPAN> 
        $.<SPAN style="COLOR: #660066">each</SPAN><SPAN style="COLOR: #009900">(</SPAN> data.<SPAN style="COLOR: #660066">weatherinfo</SPAN> <SPAN style="COLOR: #339933">,</SPAN> <SPAN style="COLOR: #000066"><STRONG>function</STRONG></SPAN><SPAN style="COLOR: #009900">(</SPAN> key <SPAN style="COLOR: #339933">,</SPAN> val <SPAN style="COLOR: #009900">)</SPAN> <SPAN style="COLOR: #009900">{</SPAN> 
            info.<SPAN style="COLOR: #660066">push</SPAN><SPAN style="COLOR: #009900">(</SPAN>key <SPAN style="COLOR: #339933">+</SPAN> <SPAN style="COLOR: #3366cc">":"</SPAN> <SPAN style="COLOR: #339933">+</SPAN> val <SPAN style="COLOR: #009900">)</SPAN><SPAN style="COLOR: #339933">;</SPAN> 
        <SPAN style="COLOR: #009900">}</SPAN><SPAN style="COLOR: #009900">)</SPAN> 
        console.<SPAN style="COLOR: #660066">log</SPAN><SPAN style="COLOR: #009900">(</SPAN>info<SPAN style="COLOR: #009900">)</SPAN><SPAN style="COLOR: #339933">;</SPAN> 
        $<SPAN style="COLOR: #009900">(</SPAN><SPAN style="COLOR: #3366cc">"pre"</SPAN><SPAN style="COLOR: #009900">)</SPAN>.<SPAN style="COLOR: #660066">html</SPAN><SPAN style="COLOR: #009900">(</SPAN> info.<SPAN style="COLOR: #660066">join</SPAN><SPAN style="COLOR: #009900">(</SPAN><SPAN style="COLOR: #3366cc">",<SPAN style="COLOR: #000099"><STRONG>\n</STRONG></SPAN>"</SPAN><SPAN style="COLOR: #009900">)</SPAN><SPAN style="COLOR: #009900">)</SPAN><SPAN style="COLOR: #339933">;</SPAN> 
    <SPAN style="COLOR: #009900">}</SPAN><SPAN style="COLOR: #009900">)</SPAN> 
<SPAN style="COLOR: #009900">}</SPAN><SPAN style="COLOR: #009900">)</SPAN></SPAN> 

var baseUrl = "http://demo.alphatr.com/weather/info.php";
 
// 將獲取的省市區列表 JSON 格式轉換為 HTML 字符串
var appendData = function( data , el ) {
 var list = [];
 $.each(data, function( key, val ){
  // console.log(key);
  list.push('<option value="' + key + '">' + val + '</option>');
 })
 $(el).html(list.join(''));
}
/* 三級聯動 */
// 獲取省列表
$.getJSON( baseUrl + "?get=province&callback=?" , function (data) {
 appendData( data , "#province" );
 var provCode = $("#province").val(); // 省 ID
 // 根據省 ID 獲取市列表
 $.getJSON( baseUrl + "?get=city&citycode=" + provCode + "&callback=?" , function (data) {
  appendData( data , "#city" );
  var cityCode = $("#city").val(); // 市 ID
  // 獲取區 列表
  $.getJSON( baseUrl + "?get=town&citycode=" + provCode + cityCode + "&callback=?" , function (data) {
   appendData( data , "#town" );
  })
 })
})
 
/* 相應值的改變 */
$("#province").bind( "change" , function(){
 var provCode = $("#province").val();
 $.getJSON( baseUrl + "?get=city&citycode=" + provCode + "&callback=?" , function (data) {
  appendData( data , "#city" );
  var cityCode = $("#city").val();
  $.getJSON( baseUrl + "?get=town&citycode=" + provCode + cityCode + "&callback=?" , function (data) {
   appendData( data , "#town" );
  })
 })
})
 
$("#city").bind( "change" , function(){
 var provCode = $("#province").val();
 var cityCode = $("#city").val();
 $.getJSON( baseUrl + "?get=town&citycode=" + provCode + cityCode + "&callback=?" , function (data) {
  appendData( data , "#town" );
 })
})
 
// 響應獲取按鈕
$("#btn").bind( "click" , function() {
 var code = $("#province").val();
 if( $("#city").val() == "00" ) {
  code += $("#town").val();
  code += $("#city").val();
 } else {
  code += $("#city").val();
  code += $("#town").val();
 }
 console.log(code);
 // 獲取天氣數據
 $.getJSON( baseUrl + "?get=weather&citycode=" + code + "&callback=?" , function (data) {
  console.log(data);
  var info = [];
  $.each( data.weatherinfo , function( key , val ) {
   info.push(key + ":" + val );
  })
  console.log(info);
  $("pre").html( info.join(",\n"));
 })
})

需要注意的是在直轄市的獲取中,每次市的返回值都是 00,而地區的 ID 不是直轄市+市+區,而是直轄市+區+00,例如上海崇明的 code 是 10102 11 00,而不是 10102 00 11。

完整的代碼可以直接看 Demo 的源碼,Demo just is demo,肯定功能不全,其他的比如根據 IP 判斷地區然後顯示,將選擇後的地區代碼存儲進 cookie 中等等都是可以加的~

下面給出天氣數據的解釋
先是天氣預報的數據

 

 [php]
<SPAN style="FONT-SIZE: 14px">city<SPAN style="COLOR: #339933">:</SPAN>西安<SPAN style="COLOR: #339933">,</SPAN> <SPAN style="COLOR: #666666">// 地區名稱</SPAN>  
city_en<SPAN style="COLOR: #339933">:</SPAN>xian<SPAN style="COLOR: #339933">,</SPAN> <SPAN style="COLOR: #666666">// 英文 (漢語拼音) 名稱</SPAN>  
date_y<SPAN style="COLOR: #339933">:</SPAN><SPAN style="COLOR: #cc66cc">2012</SPAN>年<SPAN style="COLOR: #cc66cc">8</SPAN>月<SPAN style="COLOR: #cc66cc">30</SPAN>日<SPAN style="COLOR: #339933">,</SPAN><SPAN style="COLOR: #666666">// 當前日期</SPAN>  
<SPAN style="COLOR: #990000">date</SPAN><SPAN style="COLOR: #339933">:,</SPAN> <SPAN style="COLOR: #666666">// 網上解釋是陰歷年</SPAN>  
week<SPAN style="COLOR: #339933">:</SPAN>星期四<SPAN style="COLOR: #339933">,</SPAN> <SPAN style="COLOR: #666666">// 星期</SPAN>  
fchh<SPAN style="COLOR: #339933">:</SPAN><SPAN style="COLOR: #cc66cc">18</SPAN><SPAN style="COLOR: #339933">,</SPAN> <SPAN style="COLOR: #666666">// 更新點時間 (18點)</SPAN>  
cityid<SPAN style="COLOR: #339933">:</SPAN><SPAN style="COLOR: #cc66cc">101110101</SPAN><SPAN style="COLOR: #339933">,</SPAN> <SPAN style="COLOR: #666666">// 地區 ID</SPAN>  
  
<SPAN style="COLOR: #666666">// 六天的溫度</SPAN>  
temp1<SPAN style="COLOR: #339933">:</SPAN><SPAN style="COLOR: #cc66cc">21</SPAN>℃~<SPAN style="COLOR: #cc66cc">28</SPAN>℃<SPAN style="COLOR: #339933">,</SPAN> <SPAN style="COLOR: #666666">// 在更新點之前是今日最高溫到午夜的最低溫,在更新點之後是今日午夜的最低溫到明日的最高溫</SPAN>  
temp2<SPAN style="COLOR: #339933">:</SPAN><SPAN style="COLOR: #cc66cc">18</SPAN>℃~<SPAN style="COLOR: #cc66cc">22</SPAN>℃<SPAN style="COLOR: #339933">,</SPAN> <SPAN style="COLOR: #666666">// 以此類推</SPAN>  
temp3<SPAN style="COLOR: #339933">:</SPAN><SPAN style="COLOR: #cc66cc">17</SPAN>℃~<SPAN style="COLOR: #cc66cc">26</SPAN>℃<SPAN style="COLOR: #339933">,</SPAN> 
temp4<SPAN style="COLOR: #339933">:</SPAN><SPAN style="COLOR: #cc66cc">16</SPAN>℃~<SPAN style="COLOR: #cc66cc">28</SPAN>℃<SPAN style="COLOR: #339933">,</SPAN> 
temp5<SPAN style="COLOR: #339933">:</SPAN><SPAN style="COLOR: #cc66cc">16</SPAN>℃~<SPAN style="COLOR: #cc66cc">29</SPAN>℃<SPAN style="COLOR: #339933">,</SPAN> 
temp6<SPAN style="COLOR: #339933">:</SPAN><SPAN style="COLOR: #cc66cc">17</SPAN>℃~<SPAN style="COLOR: #cc66cc">30</SPAN>℃<SPAN style="COLOR: #339933">,</SPAN> 
<SPAN style="COLOR: #666666">// 華氏溫度</SPAN>  
tempF1<SPAN style="COLOR: #339933">:</SPAN><SPAN style="COLOR: #800080">69.8</SPAN>℉~<SPAN style="COLOR: #800080">82.4</SPAN>℉<SPAN style="COLOR: #339933">,</SPAN>  
tempF2<SPAN style="COLOR: #339933">:</SPAN><SPAN style="COLOR: #800080">64.4</SPAN>℉~<SPAN style="COLOR: #800080">71.6</SPAN>℉<SPAN style="COLOR: #339933">,</SPAN> 
tempF3<SPAN style="COLOR: #339933">:</SPAN><SPAN style="COLOR: #800080">62.6</SPAN>℉~<SPAN style="COLOR: #800080">78.8</SPAN>℉<SPAN style="COLOR: #339933">,</SPAN> 
tempF4<SPAN style="COLOR: #339933">:</SPAN><SPAN style="COLOR: #800080">60.8</SPAN>℉~<SPAN style="COLOR: #800080">82.4</SPAN>℉<SPAN style="COLOR: #339933">,</SPAN> 
tempF5<SPAN style="COLOR: #339933">:</SPAN><SPAN style="COLOR: #800080">60.8</SPAN>℉~<SPAN style="COLOR: #800080">84.2</SPAN>℉<SPAN style="COLOR: #339933">,</SPAN> 
tempF6<SPAN style="COLOR: #339933">:</SPAN><SPAN style="COLOR: #800080">62.6</SPAN>℉~<SPAN style="COLOR: #cc66cc">86</SPAN>℉<SPAN style="COLOR: #339933">,</SPAN> 
<SPAN style="COLOR: #666666">// 天氣描述,同樣根據更新點確定 weather1 是今天還是明天的</SPAN>  
weather1<SPAN style="COLOR: #339933">:</SPAN>陰轉中雨<SPAN style="COLOR: #339933">,</SPAN> 
weather2<SPAN style="COLOR: #339933">:</SPAN>中雨轉大雨<SPAN style="COLOR: #339933">,</SPAN> 
weather3<SPAN style="COLOR: #339933">:</SPAN>小到中雨轉多雲<SPAN style="COLOR: #339933">,</SPAN> 
weather4<SPAN style="COLOR: #339933">:</SPAN>多雲轉晴<SPAN style="COLOR: #339933">,</SPAN> 
weather5<SPAN style="COLOR: #339933">:</SPAN>晴<SPAN style="COLOR: #339933">,</SPAN> 
weather6<SPAN style="COLOR: #339933">:</SPAN>晴轉多雲<SPAN style="COLOR: #339933">,</SPAN> 
<SPAN style="COLOR: #666666">// 12 幅圖片對應六天的天氣,更新點前就是今日白天,今日夜間,明日白天,明日夜間,更新點之後就是今日夜間開始的</SPAN>  
img1<SPAN style="COLOR: #339933">:</SPAN><SPAN style="COLOR: #cc66cc">2</SPAN><SPAN style="COLOR: #339933">,</SPAN> <SPAN style="COLOR: #666666">//陰天</SPAN>  
img2<SPAN style="COLOR: #339933">:</SPAN><SPAN style="COLOR: #cc66cc">8</SPAN><SPAN style="COLOR: #339933">,</SPAN> <SPAN style="COLOR: #666666">// 中雨,和一圖片對應天氣的陰轉中雨</SPAN>  
img3<SPAN style="COLOR: #339933">:</SPAN><SPAN style="COLOR: #cc66cc">8</SPAN><SPAN style="COLOR: #339933">,</SPAN> <SPAN style="COLOR: #666666">// 依次類推</SPAN>  
img4<SPAN style="COLOR: #339933">:</SPAN><SPAN style="COLOR: #cc66cc">9</SPAN><SPAN style="COLOR: #339933">,</SPAN> 
img5<SPAN style="COLOR: #339933">:</SPAN><SPAN style="COLOR: #cc66cc">21</SPAN><SPAN style="COLOR: #339933">,</SPAN> 
img6<SPAN style="COLOR: #339933">:</SPAN><SPAN style="COLOR: #cc66cc">1</SPAN><SPAN style="COLOR: #339933">,</SPAN> 
img7<SPAN style="COLOR: #339933">:</SPAN><SPAN style="COLOR: #cc66cc">1</SPAN><SPAN style="COLOR: #339933">,</SPAN> 
img8<SPAN style="COLOR: #339933">:</SPAN><SPAN style="COLOR: #cc66cc">0</SPAN><SPAN style="COLOR: #339933">,</SPAN> 
img9<SPAN style="COLOR: #339933">:</SPAN><SPAN style="COLOR: #cc66cc">0</SPAN><SPAN style="COLOR: #339933">,</SPAN> <SPAN style="COLOR: #666666">// 晴</SPAN>  
img10<SPAN style="COLOR: #339933">:</SPAN><SPAN style="COLOR: #cc66cc">99</SPAN><SPAN style="COLOR: #339933">,</SPAN> <SPAN style="COLOR: #666666">// 第五天是晴,沒有 "轉" 了,所以這幅圖片是無效占位,和前一幅顯示相同</SPAN>  
img11<SPAN style="COLOR: #339933">:</SPAN><SPAN style="COLOR: #cc66cc">0</SPAN><SPAN style="COLOR: #339933">,</SPAN> 
img12<SPAN style="COLOR: #339933">:</SPAN><SPAN style="COLOR: #cc66cc">1</SPAN><SPAN style="COLOR: #339933">,</SPAN> 
img_single<SPAN style="COLOR: #339933">:</SPAN><SPAN style="COLOR: #cc66cc">8</SPAN><SPAN style="COLOR: #339933">,</SPAN> 
<SPAN style="COLOR: #666666">// 分別對應圖片的描述</SPAN>  
img_title1<SPAN style="COLOR: #339933">:</SPAN>陰<SPAN style="COLOR: #339933">,</SPAN> 
img_title2<SPAN style="COLOR: #339933">:</SPAN>中雨<SPAN style="COLOR: #339933">,</SPAN> 
img_title3<SPAN style="COLOR: #339933">:</SPAN>中雨<SPAN style="COLOR: #339933">,</SPAN> 
img_title4<SPAN style="COLOR: #339933">:</SPAN>大雨<SPAN style="COLOR: #339933">,</SPAN> 
img_title5<SPAN style="COLOR: #339933">:</SPAN>小到中雨<SPAN style="COLOR: #339933">,</SPAN> 
img_title6<SPAN style="COLOR: #339933">:</SPAN>多雲<SPAN style="COLOR: #339933">,</SPAN> 
img_title7<SPAN style="COLOR: #339933">:</SPAN>多雲<SPAN style="COLOR: #339933">,</SPAN> 
img_title8<SPAN style="COLOR: #339933">:</SPAN>晴<SPAN style="COLOR: #339933">,</SPAN> 
img_title9<SPAN style="COLOR: #339933">:</SPAN>晴<SPAN style="COLOR: #339933">,</SPAN> 
img_title10<SPAN style="COLOR: #339933">:</SPAN>晴<SPAN style="COLOR: #339933">,</SPAN> 
img_title11<SPAN style="COLOR: #339933">:</SPAN>晴<SPAN style="COLOR: #339933">,</SPAN> 
img_title12<SPAN style="COLOR: #339933">:</SPAN>多雲<SPAN style="COLOR: #339933">,</SPAN> 
img_title_single<SPAN style="COLOR: #339933">:</SPAN>中雨<SPAN style="COLOR: #339933">,</SPAN> 
<SPAN style="COLOR: #666666">// 六天的風力和風向</SPAN>  
wind1<SPAN style="COLOR: #339933">:</SPAN>西風小於<SPAN style="COLOR: #cc66cc">3</SPAN>級轉<SPAN style="COLOR: #cc66cc">3</SPAN><SPAN style="COLOR: #339933">-</SPAN><SPAN style="COLOR: #cc66cc">4</SPAN>級<SPAN style="COLOR: #339933">,</SPAN> 
wind2<SPAN style="COLOR: #339933">:</SPAN>西風<SPAN style="COLOR: #cc66cc">3</SPAN><SPAN style="COLOR: #339933">-</SPAN><SPAN style="COLOR: #cc66cc">4</SPAN>級<SPAN style="COLOR: #339933">,</SPAN> 
wind3<SPAN style="COLOR: #339933">:</SPAN>旋轉風小於<SPAN style="COLOR: #cc66cc">3</SPAN>級<SPAN style="COLOR: #339933">,</SPAN> 
wind4<SPAN style="COLOR: #339933">:</SPAN>旋轉風小於<SPAN style="COLOR: #cc66cc">3</SPAN>級<SPAN style="COLOR: #339933">,</SPAN> 
wind5<SPAN style="COLOR: #339933">:</SPAN>旋轉風小於<SPAN style="COLOR: #cc66cc">3</SPAN>級<SPAN style="COLOR: #339933">,</SPAN> 
wind6<SPAN style="COLOR: #339933">:</SPAN>旋轉風小於<SPAN style="COLOR: #cc66cc">3</SPAN>級<SPAN style="COLOR: #339933">,</SPAN> 
<SPAN style="COLOR: #666666">// 今明的風向</SPAN>  
fx1<SPAN style="COLOR: #339933">:</SPAN>西風<SPAN style="COLOR: #339933">,</SPAN> 
fx2<SPAN style="COLOR: #339933">:</SPAN>西風<SPAN style="COLOR: #339933">,</SPAN> 
<SPAN style="COLOR: #666666">// 六天的風力(和風向分開了)</SPAN>  
fl1<SPAN style="COLOR: #339933">:</SPAN>小於<SPAN style="COLOR: #cc66cc">3</SPAN>級轉<SPAN style="COLOR: #cc66cc">3</SPAN><SPAN style="COLOR: #339933">-</SPAN><SPAN style="COLOR: #cc66cc">4</SPAN>級<SPAN style="COLOR: #339933">,</SPAN> 
fl2<SPAN style="COLOR: #339933">:</SPAN><SPAN style="COLOR: #cc66cc">3</SPAN><SPAN style="COLOR: #339933">-</SPAN><SPAN style="COLOR: #cc66cc">4</SPAN>級<SPAN style="COLOR: #339933">,</SPAN> 
fl3<SPAN style="COLOR: #339933">:</SPAN>小於<SPAN style="COLOR: #cc66cc">3</SPAN>級<SPAN style="COLOR: #339933">,</SPAN> 
fl4<SPAN style="COLOR: #339933">:</SPAN>小於<SPAN style="COLOR: #cc66cc">3</SPAN>級<SPAN style="COLOR: #339933">,</SPAN> 
fl5<SPAN style="COLOR: #339933">:</SPAN>小於<SPAN style="COLOR: #cc66cc">3</SPAN>級<SPAN style="COLOR: #339933">,</SPAN> 
fl6<SPAN style="COLOR: #339933">:</SPAN>小於<SPAN style="COLOR: #cc66cc">3</SPAN>級<SPAN style="COLOR: #339933">,</SPAN> 
<SPAN style="COLOR: #666666">// 生活指數,也和更新點有關系</SPAN>  
index<SPAN style="COLOR: #339933">:</SPAN>熱<SPAN style="COLOR: #339933">,</SPAN> <SPAN style="COLOR: #666666">// 一天舒適度</SPAN>  
index_d<SPAN style="COLOR: #339933">:</SPAN>天氣較熱,建議著短裙、短褲、短套裝、T恤等夏季服裝。年老體弱者宜著長袖襯衫和單褲。<SPAN style="COLOR: #339933">,</SPAN> <SPAN style="COLOR: #666666">// 一天舒適度的描述</SPAN>  
index48<SPAN style="COLOR: #339933">:</SPAN>舒適<SPAN style="COLOR: #339933">,</SPAN> <SPAN style="COLOR: #666666">//兩天的舒適度(48小時)</SPAN>  
index48_d<SPAN style="COLOR: #339933">:</SPAN>建議著薄型套裝或牛仔衫褲等春秋過渡裝。年老體弱者宜著套裝、夾克衫等。<SPAN style="COLOR: #339933">,</SPAN> <SPAN style="COLOR: #666666">// 描述</SPAN>  
index_uv<SPAN style="COLOR: #339933">:</SPAN>弱<SPAN style="COLOR: #339933">,</SPAN> <SPAN style="COLOR: #666666">// 一天的紫外線指數</SPAN>  
index48_uv<SPAN style="COLOR: #339933">:</SPAN>最弱<SPAN style="COLOR: #339933">,</SPAN> <SPAN style="COLOR: #666666">// 兩天紫外線指數</SPAN>  
index_xc<SPAN style="COLOR: #339933">:</SPAN>不宜<SPAN style="COLOR: #339933">,</SPAN> <SPAN style="COLOR: #666666">// 洗車指數</SPAN>  
index_tr<SPAN style="COLOR: #339933">:</SPAN>一般<SPAN style="COLOR: #339933">,</SPAN> <SPAN style="COLOR: #666666">// 旅游指數</SPAN>  
index_co<SPAN style="COLOR: #339933">:</SPAN>較舒適<SPAN style="COLOR: #339933">,</SPAN> <SPAN style="COLOR: #666666">//舒適度指數</SPAN>  
st1<SPAN style="COLOR: #339933">:</SPAN><SPAN style="COLOR: #cc66cc">24</SPAN><SPAN style="COLOR: #339933">,</SPAN> <SPAN style="COLOR: #666666">// 這些不知道干啥的~</SPAN>  
st2<SPAN style="COLOR: #339933">:</SPAN><SPAN style="COLOR: #cc66cc">20</SPAN><SPAN style="COLOR: #339933">,</SPAN> 
st3<SPAN style="COLOR: #339933">:</SPAN><SPAN style="COLOR: #cc66cc">17</SPAN><SPAN style="COLOR: #339933">,</SPAN> 
st4<SPAN style="COLOR: #339933">:</SPAN><SPAN style="COLOR: #cc66cc">14</SPAN><SPAN style="COLOR: #339933">,</SPAN> 
st5<SPAN style="COLOR: #339933">:</SPAN><SPAN style="COLOR: #cc66cc">26</SPAN><SPAN style="COLOR: #339933">,</SPAN> 
st6<SPAN style="COLOR: #339933">:</SPAN><SPAN style="COLOR: #cc66cc">15</SPAN><SPAN style="COLOR: #339933">,</SPAN> 
index_cl<SPAN style="COLOR: #339933">:</SPAN>不宜<SPAN style="COLOR: #339933">,</SPAN> <SPAN style="COLOR: #666666">// 晨練指數</SPAN>  
index_ls<SPAN style="COLOR: #339933">:</SPAN>不宜<SPAN style="COLOR: #339933">,</SPAN> <SPAN style="COLOR: #666666">// 晾曬指數</SPAN>  
index_ag<SPAN style="COLOR: #339933">:</SPAN>極易發 <SPAN style="COLOR: #666666">// 息斯敏過敏氣象指數(我也不知道干啥的~)</SPAN></SPAN> 

city:西安, // 地區名稱
city_en:xian, // 英文 (漢語拼音) 名稱
date_y:2012年8月30日,// 當前日期
date:, // 網上解釋是陰歷年
week:星期四, // 星期
fchh:18, // 更新點時間 (18點)
cityid:101110101, // 地區 ID
 
// 六天的溫度
temp1:21℃~28℃, // 在更新點之前是今日最高溫到午夜的最低溫,在更新點之後是今日午夜的最低溫到明日的最高溫
temp2:18℃~22℃, // 以此類推
temp3:17℃~26℃,
temp4:16℃~28℃,
temp5:16℃~29℃,
temp6:17℃~30℃,
// 華氏溫度
tempF1:69.8℉~82.4℉,
tempF2:64.4℉~71.6℉,
tempF3:62.6℉~78.8℉,
tempF4:60.8℉~82.4℉,
tempF5:60.8℉~84.2℉,
tempF6:62.6℉~86℉,
// 天氣描述,同樣根據更新點確定 weather1 是今天還是明天的
weather1:陰轉中雨,
weather2:中雨轉大雨,
weather3:小到中雨轉多雲,
weather4:多雲轉晴,
weather5:晴,
weather6:晴轉多雲,
// 12 幅圖片對應六天的天氣,更新點前就是今日白天,今日夜間,明日白天,明日夜間,更新點之後就是今日夜間開始的
img1:2, //陰天
img2:8, // 中雨,和一圖片對應天氣的陰轉中雨
img3:8, // 依次類推
img4:9,
img5:21,
img6:1,
img7:1,
img8:0,
img9:0, // 晴
img10:99, // 第五天是晴,沒有 "轉" 了,所以這幅圖片是無效占位,和前一幅顯示相同
img11:0,
img12:1,
img_single:8,
// 分別對應圖片的描述
img_title1:陰,
img_title2:中雨,
img_title3:中雨,
img_title4:大雨,
img_title5:小到中雨,
img_title6:多雲,
img_title7:多雲,
img_title8:晴,
img_title9:晴,
img_title10:晴,
img_title11:晴,
img_title12:多雲,
img_title_single:中雨,
// 六天的風力和風向
wind1:西風小於3級轉3-4級,
wind2:西風3-4級,
wind3:旋轉風小於3級,
wind4:旋轉風小於3級,
wind5:旋轉風小於3級,
wind6:旋轉風小於3級,
// 今明的風向
fx1:西風,
fx2:西風,
// 六天的風力(和風向分開了)
fl1:小於3級轉3-4級,
fl2:3-4級,
fl3:小於3級,
fl4:小於3級,
fl5:小於3級,
fl6:小於3級,
// 生活指數,也和更新點有關系
index:熱, // 一天舒適度
index_d:天氣較熱,建議著短裙、短褲、短套裝、T恤等夏季服裝。年老體弱者宜著長袖襯衫和單褲。, // 一天舒適度的描述
index48:舒適, //兩天的舒適度(48小時)
index48_d:建議著薄型套裝或牛仔衫褲等春秋過渡裝。年老體弱者宜著套裝、夾克衫等。, // 描述
index_uv:弱, // 一天的紫外線指數
index48_uv:最弱, // 兩天紫外線指數
index_xc:不宜, // 洗車指數
index_tr:一般, // 旅游指數
index_co:較舒適, //舒適度指數
st1:24, // 這些不知道干啥的~
st2:20,
st3:17,
st4:14,
st5:26,
st6:15,
index_cl:不宜, // 晨練指數
index_ls:不宜, // 晾曬指數
index_ag:極易發 // 息斯敏過敏氣象指數(我也不知道干啥的~)

實時天氣的數據

 

 [php]
<SPAN style="FONT-SIZE: 14px">city<SPAN style="COLOR: #339933">:</SPAN>西安<SPAN style="COLOR: #339933">,</SPAN> <SPAN style="COLOR: #666666">// 地區名</SPAN>  
cityid<SPAN style="COLOR: #339933">:</SPAN><SPAN style="COLOR: #cc66cc">101110101</SPAN><SPAN style="COLOR: #339933">,</SPAN> <SPAN style="COLOR: #666666">// 地區 ID</SPAN>  
temp1<SPAN style="COLOR: #339933">:</SPAN><SPAN style="COLOR: #cc66cc">21</SPAN>℃<SPAN style="COLOR: #339933">,</SPAN> <SPAN style="COLOR: #666666">// 今天夜間溫度</SPAN>  
temp2<SPAN style="COLOR: #339933">:</SPAN><SPAN style="COLOR: #cc66cc">28</SPAN>℃<SPAN style="COLOR: #339933">,</SPAN> <SPAN style="COLOR: #666666">// 明天白天溫度</SPAN>  
weather<SPAN style="COLOR: #339933">:</SPAN>陰轉中雨<SPAN style="COLOR: #339933">,</SPAN> <SPAN style="COLOR: #666666">// 天氣描述</SPAN>  
img1<SPAN style="COLOR: #339933">:</SPAN>n2<SPAN style="COLOR: #339933">.</SPAN>gif<SPAN style="COLOR: #339933">,</SPAN> <SPAN style="COLOR: #666666">// 今天夜間天氣圖片 n 表示 night</SPAN>  
img2<SPAN style="COLOR: #339933">:</SPAN>d8<SPAN style="COLOR: #339933">.</SPAN>gif<SPAN style="COLOR: #339933">,</SPAN> <SPAN style="COLOR: #666666">// 明天白天天氣圖片 d 表示 day</SPAN>  
ptime<SPAN style="COLOR: #339933">:</SPAN><SPAN style="COLOR: #cc66cc">18</SPAN><SPAN style="COLOR: #339933">:</SPAN><SPAN style="COLOR: #208080">00</SPAN> <SPAN style="COLOR: #666666">// 更新時間</SPAN></SPAN> 

city:西安, // 地區名
cityid:101110101, // 地區 ID
temp1:21℃, // 今天夜間溫度
temp2:28℃, // 明天白天溫度
weather:陰轉中雨, // 天氣描述
img1:n2.gif, // 今天夜間天氣圖片 n 表示 night
img2:d8.gif, // 明天白天天氣圖片 d 表示 day
ptime:18:00 // 更新時間

同樣的,天氣和更新點是由關系的,前半天天氣就是今天白天和夜間,這個實時溫度更新的比較頻繁~
 

 

  1. 上一頁:
  2. 下一頁:
蘋果刷機越獄教程| IOS教程問題解答| IOS技巧綜合| IOS7技巧| IOS8教程
Copyright © Ios教程網 All Rights Reserved