jQuery 显示来自示例 url 的 Json 数据
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15454342/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Displaying Json data from example url
提问by racemic
I know this has been asked before, but I'm struggling to see what is wrong with my code here as I'm still getting a blank page:
我知道以前有人问过这个问题,但是我很难在这里看到我的代码有什么问题,因为我仍然得到一个空白页面:
Jquery is included in the page
页面中包含jquery
(url from http://www.geonames.org/export/JSON-webservices.html)
(来自http://www.geonames.org/export/JSON-webservices.html 的网址)
var url="http://api.geonames.org/citiesJSON?north=44.1&south=-9.9&east=-22.4&west=55.2&lang=de&username=demo";
$.getJSON(url, function (data) {
$.each(data.geonames, function (){
$('ul#results').append('<li><div class=\"name\">' +this.toponymName+ '</div></li>');
});
});
I've tried saving the file locally as replacing the url with 'test.json' but nothing there too. Any ideas or syntax I'm missing here?
我尝试将文件保存在本地,将 url 替换为“test.json”,但也没有。我在这里缺少任何想法或语法?
采纳答案by roman m
Hit the url from your browser: http://api.geonames.org/citiesJSON?north=44.1&south=-9.9&east=-22.4&west=55.2&lang=de&username=demo
从浏览器中点击 url:http: //api.geonames.org/citiesJSON?north=44.1&south=-9.9&east=-22.4&west=55.2&lang=de&username=demo
You'll see that the "the hourly limit of 2000 credits for demo has been exceeded. Please use an application specific account. Do not use the demo account for your application."
您会看到“已超出演示的每小时 2000 积分限制。请使用特定于应用程序的帐户。不要将演示帐户用于您的应用程序。”