i used the IP-API ’ http://ip-api.com/json ’ to get the lng and lat of my location using my ip address but it seems that it’s not working.
i used this
$.getJSON('https://ip-api.com/json', function(json){
lat = json.lat;
lng = json.lon;
});
but when I log the lat or the lng it’s appear that both are undefined
Does ip-api.com
support https
?
no it does not, but even with http nothing work.
Is your codepen address http
?
yes it is that why i could not figure out what the problem. .
Post the link to your codepen.
before that I’m trying to get the latitude and longitude, so it didn’t work i mean before calling the weather map api
.
Works for me. I get my coords in console.
function getLatLon(){
$.getJSON('http://ip-api.com/json', function(json){
lat = json.lat;
lng = json.lon;
console.log(lat, lng) // <-- This shows my coords in console
});
}
So why it’s not working for me.
i just try it in my brother’s computer and it worked perfectly, so what do you think the problem is?
Are you getting a response in your browser if you just click the link directly?
http://ip-api.com/json
yes when i do that i got a response.
Post the screenshot of your Chrome console.
well i was using fireFox now i switched to chrome and it worked thank for your time,
i was wondering why in fireFox didn’t work?
Works in FF for me