Ok so…i’m not (yet!) a professionist, but i noticed i couple of things:
The API key stuff, since your going to put the code in a public place it’s suggested not to insert private things
Try to separate functions: i see a .click() binding into a getJson (asynchronous) into the getLoc func^^
In this specific case, i will separate the click stuff and use it to trigger a function of conversion ^^ I mean you have the °C / °F label so clicking the label will trigger the conversion stuff. This is a logic indipendent from the Json or whatever data you consider, so it should be implemented separately into the code.
about the specific issue, the conversion function you implemented is
var fahTemp = Math.round(parseInt($("#temp").text()) * 9 / 5 + 32)
At this point you have the °F temperature, there’s no way to come back from here.
This is how i adapted your function triyng to change the less i can:
var currentTempUnit = $("#tempUnit").text();
//var newTempUnit = currentTempUnit == “C” ? “F” : “C”;
currentTempUnit == “C” ? newTempUnit=“F” : newTempUnit=“C”;
//added update unit
if (newTempUnit === “F”)
var fahTemp = Math.round(parseInt($("#temp").text()) * 9 / 5 + 32);
var celTemp = Math.round((parseInt($("#temp").text()) - 32) * 5 / 9 );
It works, but you need to uniform it to your code ^^
Let me know if it helps^^
The data problem i had before was due to the geolocalization ( disabled in all my browser); i had others problems related to graphics (i.e. coudn’t see the F once translated ) but that were problems related to my configuration i guess.