I want to get weather from OpenWeatherMap API based on latitude and longitude, but I'm getting error
net::ERR_CONNECTION_REFUSED
Project is on codepen.io
var appid = "myID";
function getLocation() {
$.getJSON('https://geoip-db.com/json/geoip.php?jsonp=?')
.done (function(location)
{
$('.country').html(location.country_name);
$('.city').html(location.city);
var lat = location.latitude;
var lon = location.longitude;
var weatherLink = "https://api.openweathermap.org/data/2.5/weather?lat=" + lat + "&lon=" + lon + "&appid=" + appid + "&callback=?";
$('body').append(weatherLink);
$.ajax({
url: weatherLink,
dataType: "jsonp",
success: function(response) {
$('body').append(response);
}
});
});
}
$(document).ready(function() {
getLocation();
});
I'm using https://geoip-db.com/ to get latitude and longitude. URL (weatherLink) is correct. Full error:
GET https://api.openweathermap.org/data/2.5/weather?lat=51.1&lon=17.0333&appid=…0b9873ed&callback=jQuery22406914555127333375_1469796455615&_=1469796455617 net::ERR_CONNECTION_REFUSED