js定位当前城市,获得当前城市的天气
来源:互联网 发布:nginx 代理iis 编辑:程序博客网 时间:2024/06/05 17:33
/** * 定位当前城市 */ 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 = getCookie('ccity'); if(relName==null){ locationInit() relName = $("#cityName").html(); } $("#cityName").html(relName); var todayimg = ''; var tomorrowimg = ''; $.ajax({ url:"http://api.map.baidu.com/telematics/v3/weather", type:"get", data:{ location:relName, output:'json', ak:'6tYzTvGZSOpYB5Oc2YGGOKt8' }, /*预期服务器端返回的数据类型,假设现在跨域了,就改成jsonp 就可以了 */ dataType:"jsonp", success:function(data){ var weatherData=data.results[0].weather_data; //console.log(weatherData) } }) }
阅读全文
0 0
- js定位当前城市,获得当前城市的天气
- js获取当前城市,并根据当前城市获得当地天气
- android 定位当前城市
- ios 定位当前城市
- 百度定位当前城市
- iOS 定位当前城市
- ios定位当前城市
- iOS8 定位当前城市
- Unity获取当前城市天气
- 基于百度定位获取当前城市请求天气信息
- Android定位当前城市的实现
- 百度地图定位当前城市
- ajax获取当前城市天气情况
- js实现PC端根据IP定位当前城市地理位置
- 获取当前城市的城市名
- Fragment中实现自动定位当前城市,点击刷新按钮更新天气信息
- 一个用来定位当前城市的单例
- Android中通过当前经纬度获得城市
- vs工程项目修改继承的值
- 基础练习 矩阵乘法
- 更改 Windows VM 的可用性集
- 搭建一个属于自己的博客(Hexo + GitHub)
- jQuery选择器
- js定位当前城市,获得当前城市的天气
- HashMap循环遍历方式及其性能对比
- 【cordova】cordova安装步骤(windows)
- Rhyme/算法之简单版桶排序
- nginx负载均衡配置
- IC卡安全操作基本命令-取随机数(GET CHALLENGE)
- 以匠人之心,做最完美的产品
- Android 的进程间通信 Binder——AIDL的入门使用(二)
- SpringMVC 之 BUG集中篇