function get_weather(o) { //跨域获取天气信息
var code = o.val();
$.ajax({
type: "get",
async: false,
cache: false,
url: "get_json.php",
dataType: "jsonp",
data: {
code_city: code
},
jsonpCallback: "weather_callback",
beforeSend: function() {
$(".box").html("")
},
success: function(msg) {
var w_str = "";
var img2 = msg.weatherinfo.img2 != 99 ? "-": "";
var img4 = msg.weatherinfo.img4 != 99 ? "-": "";
var img6 = msg.weatherinfo.img6 != 99 ? "-": "";
var temp1 = sort_wd(msg.weatherinfo.temp1);
var temp2 = sort_wd(msg.weatherinfo.temp2);
var temp3 = sort_wd(msg.weatherinfo.temp3);
w_str += "
"+ msg.weatherinfo.date_y+ " " + msg.weatherinfo.week+ " " + "所在城市:" + msg.weatherinfo.city + "
";w_str += "
今天:" + temp1 + " " + msg.weatherinfo.weather1 + "" + img2 + "
";w_str += "
明天:" + temp2 + " " + msg.weatherinfo.weather2 + "" + img4 + "
";w_str += "
后天:" + temp3 + " " + msg.weatherinfo.weather3 + "" + img6 + "
";$(".box").html(w_str).addClass("weather_box");
},
error: function() {
$(".box").html('加载失败!');
}
});
}