JSFiddle - React, Tailwind, and code Playground

by hippietrail

JavaScript

var lookupLanguagesWithGeonames = function(lat, lng) {

    $.getJSON('http://ws.geonames.org/countryCode', {
        lat: lat,
        lng: lng,
        type: 'JSON'
    }, function(results) {
        if (results.countryCode) {
            alert('coordinates: ' + lat + ', ' + lng + '\n' + 'languages: ' + results.languages);
        } else {
            alert('coordinates: ' + lat + ', ' + lng + '\n' + 'failed: ' + results.status.value + ' ' + results.status.message);
        }
    });
};

// Coordinates that fall within a country
lookupLanguagesWithGeonames(43.7534932, 28.5743187);

// Coordinates which are not within any country
lookupLanguagesWithGeonames(142, 124);