I’m trying to retrieve data from api.apixu.com. My browser asks me for permission to access my location but then noting happens.
function getLocation() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(success);
}
else {
alert(‘Geolocation is not supported’);
}
}
The main reason this is not working is because you have a variable Weather which is not seen in the ajax request which is inside the document ready function. At no point is the getLocation function called and that’s the first thing we want to have done when the page loads in order to get the location to be passed down to the url and then send the request for the weather.
Thank you. Before you post your answer I also had figured out the variables inside the Ajax function were in a wrong format and I couldn’t get the .text and .icon data. Your code solves all those issues. Thanks.