我正在尝试使用 jquery 中的 getJSON 函数读取 json 文件,在我想让数据出现在我的网页上之前我没有这样做
这是我的代码
var url = "http://api.openweathermap.org/data/2.5/forecast?lat=35&lon=139&callback=?" ;
$.getJSON(url, function(res) {
$('#result').html('<p>lon: ' + res.lon + '</p>');
});
这是我的 json 文件
{"coord":
{
"lon":-0.12574,
"lat":51.50853
},
"sys":
{
"country":"GB",
"sunrise":1380780339,
"sunset":1380821577
},
"weather":
[{
"id":521,
"main":"Rain",
"description":"proximity shower rain",
"icon":"09n"
}],
"base":"gdps stations",
"main":
{
"temp":290.43,
"pressure":1008,
"humidity":88,
"temp_min":289.15,
"temp_max":291.48
},
"wind":
{
"speed":3.1,
"deg":140
},
"rain":
{
"1h":1.65
},
"clouds":
{
"all":40
},
"dt":1380823503,
"id":2643743,
"name":"London",
"cod":200
}