javascriptajaxgetopenweathermap

Get the correct location of a user to display on the screen


Okay, so this is the javascript that I am using Link . The issue that I am having is that the code displays Earth for the user's location instead of the actual city. And if I change the value of

$(".currentLocation").html(city);

to

$(".currentLocation").html(data.name);

instead of a location I just get a blank.


Solution

  • Possibly because you are calling $get instead $.get() in freegeoip request.

    Also change the last line to use the getLocation()

    $(function() {
      getLocation();
    });