/**
* 定位当前城市
*/
function locationInit(){
$.getScript('http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js', function(_result) {
if (remote_ip_info.ret == '1') {
cityName = remote_ip_info.province;
// console.log(cityName)
$("#cityName").html(cityName);
}
});
* 定位当前城市
*/
function locationInit(){
$.getScript('http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js', function(_result) {
if (remote_ip_info.ret == '1') {
cityName = remote_ip_info.province;
// console.log(cityName)
$("#cityName").html(cityName);
}
});
}
/**
* 根据城市获得天气
*/
function cityWeatherInit(){
//跨域是浏览器的安全策略.
//jQuery 解决的方式.
var relName = $("#cityName").html();
var todayimg = '';
var tomorrowimg = '';
$.ajax({
url:"http://api.map.baidu.com/telematics/v3/weather",
type:"get",
data:{
location:relName,
output:'json',
ak:'秘钥'
},
/*预期服务器端返回的数据类型,假设我现在跨域了,我就改成jsonp 就可以了 */
dataType:"jsonp",
success:function(data){
var weatherData=data.results[0].weather_data;
console.log(weatherData)
}
}
})
}