结果如下所示:先打印cc1,cc222, 然后执行25行success中代码
jQuery1.5的变化,语法糖改变,遵循开发封闭原则
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
$.ajax({url: url, dataType: "jsonp" , type: "get" , data:{location:city}}) .done( function (data){ if (data.result){ var sk = data.result.sk; var today = data.result.today; var futur = data.result.future; var fut = "日期温度天气风向" ; $( '#mufeng' ).html( "<p>" + '当前: ' + sk.temp + '℃ , ' + sk.wind_direction + sk.wind_strength + ' , ' + '空气湿度' + sk.humidity + ' , 更新时间' + sk.time + "</p><p style='padding-bottom: 10px;'>" + today.city + ' 今天是: ' + today.date_y + ' ' + today.week + ' , ' + today.temperature + ' , ' + today.weather + ' , ' + today.wind + "<p></p>" ); } else { console.log( '该接口调用达到上限' ) } }) .fail( function (){ console.log( "获取数据失败" ) }) .done( function (data){ console.log(data) }) |