For my latest project, I am attempting to retrieve JSON data from a specific URL and display it on a web page using only JavaScript.
This is all new to me. Can someone assist me in fetching the JSON data from the following link:
I have been experimenting with AJAX based on some research, but so far I haven't found the right solution:
$(document).ready(function () {
$('#retrieve-resources').click(function () {
var displayResources = $('#display-resources');
displayResources.text('Fetching data from JSON source...');
$.ajax({
type: "GET",
url: "http://api.geonames.org/citiesJSON?north=44.1&south=-9.9&east=-22.4&west=55.2&lang=de&username=demo",
success: function(result)
{
console.log(result);
var output="<table><thead><tr><th>LNG</th><th>GEONAMEID</th><th>COUNTRYCODE</th></thead><tbody>";
for (var i in result)
{
output+="<tr><td>" + result.geonames[i].lng + "</td><td>" + result.geonames[i].geonameId + "</td><td>" + result.geonames[i].countrycode + "</td></tr>";
}
output+="</tbody></table>";
displayResources.html(output);
$("table").addClass("table");
}
});
});
});