$(document).ready(function(){
var lon;
var lat;
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
lon = position.coords.longitude;
lat = position.coords.latitude;
$("#data").html("latitude:" + lat + "<br>longitude:"+lon);
var api= "https://fcc-weather-api.glitch.me/api/current?lon=:"+lon+"&lat=:"+lat;
$.getJSON(api, function(data) {
var temp = "";
temp += data.main.temp;
$("weather").html(temp);
});
});
}
})
Can anyone tell why my project is not working?
I’ve edited your post for readability. When you enter a code block into the forum, precede it with a line of three backticks and follow it with a line of three backticks to make easier to read. See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (</>
) will also add backticks around text.

The first thing that I notice is that your weather url:
...lon=:"+lon+"&lat=:"+lat;...
… has colons. It should be:
...lon="+lon+"&lat="+lat;...
I think you done some minor mistakes in your code. It should be:
$('#weather').html(temp);
OR
$('.weather').html(temp);
You’re going to have to be more specific. Show us the code that you have now. Tell us what you expect it to do. Tell us what it is actually doing.
The better quality the question, the better quality the answer.
https://codepen.io/rohit357/pen/oqQBmL
This is my code. It is only showing lat and lon but it should have shown temp also.
try
$("#weather").html(temp);
instead of
$(‘weather’).html(temp);