【发布时间】:2015-07-24 20:33:01
【问题描述】:
我正在使用天气 api,我的目的是将 json 数据显示到简单的 html 视图中......
问题是(也许)上面的脚本根本不起作用,甚至警告,如果我做错了,请有人指导......
脚本和 html
<div id ="fj"></div>
$(document).ready(function() {
var teams;
$.getJSON("http://api.openweathermap.org/data/2.5/forecast/daily?lat=33.5689&lon=72.6378&cnt=10", function(dataDD) {
//do some thing with json or assign global variable to incoming json.
var tasks = $.parseJSON(dataDD.city);
alert(tasks);
//alert('empLoggedId');
$.each(tasks, function(key, value) {
$("#fj").append(data.weather.description);
});
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<div id="fj"></div>
任何类型的 hep 或参考将不胜感激 感谢您的宝贵时间
【问题讨论】:
-
你需要提供更多细节,可能还有一个 jsFiddle,否则我认为你会得到一些反对票。
-
@Suhail 你能指出你得到错误的确切行吗?
-
JSON 文件中有很多数据。如果你清楚你需要什么,那么我可以发布一个答案。
-
@根本没有控制台错误,这意味着我们遇到了属性访问问题,现在可以正常工作了,感谢大家的帮助
标签: javascript jquery json asp.net-web-api