代理的代码,用的是雅虎的代理:
$(document).ready(function() {
// 天气
$.getJSON("
http://query.yahooapis.com/v1/public/yql", {
q: "select * from json where url=\"
http://m.weather.com.cn/atad/101190101.html\"",
format: "json"
}, function(data) {
var $content = $("#content")
if (data.query.results) {
var weatherinfo = data.query.results.weatherinfo;
//console.log(weatherinfo);
var week = ["星期一","星期二","星期三","星期四","星期五","星期六","星期天","星期一","星期二"];
var week_tomorrow ="";
var week_tdat ="";
var week_today = weatherinfo.week;
var index = $.inArray(week_today,week);
week_tomorrow = week[index+1];
week_tdat = week[index+2];
$(".today .location").text(weatherinfo.city);
} else {
$(".today p:eq(1)").text("获取数据失败");
}
});