I cant figure out why my code wont show the temperature heres my code thanks for the help
js:
$(document).ready(function() {
if (navigator.geolocation.getCurrentPosition) {
navigator.geolocation.getCurrentPosition(function(position) {
var latitude = position.coords.latitude;
var longitude = position.coords.longitude;
$.getJSON("https://crossorigin.me/https://api.darksky.net/forecast/my api key/" + latitude + ',' + longitude + "?units=auto&exclude=minutily,hourly,daily,alerts", function(responseText,statusText, xhr) {
if (statusText == "success") {
var splitTimezoneArray = responseText.timezone.split("/");
console.log(splitTimezoneArray);
/* Celcius */
if (responseText.flags.units == "si") {
var celciusFlag = true;
$("#temp").html(Math.round(responseText.currently.temperature,-1) + " °C");
$("#temp").click(function() {
if (celciusFlag) {
var f = responseText.currently.temperature * 9/5 + 32;
$("#temp").html(Math.round(f,-1) + " °F");
celciusFlag = false;
} else {
$("#temp").html(Math.round(responseText.currently.temperature,-1) + " °C");
celciusFlag = true;
}
});
/* Fahrenheit */
} else {
celciusFlag = false;
$("#temp").html(Math.round(responseText.currently.temperature,-1) + " °F");
$("#temp").click(function() {
if (celciusFlag) {
$("#temp").html(Math.round(responseText.currently.temperature ,-1) + " °F");
celciusFlag = false;
} else {
var c = (responseText.currently.temperature - 32) * 5/9;
$("#temp").html(Math.round(c,-1) + " °C");
celciusFlag = true;
}
});
}
$("#summary").html(responseText.currently.summary);
} else {
$("#summary").html("There was an error");
}
});
});
}
});