Organizational Research By

Surprising Reserch Topic

how do i use a local location for a weather api using -'jquery,api'


how do i use a local location for a weather api  using -'jquery,api'

I've been stuck on this all day. Here's a link to the codepen for it.

The basic gist is to find out where the user is and to tell them the weather.

I have the code set so we can find the users location. How do I find the weather for this location? I'm not sure how to code that.

Here's the HTML

<html>
<head>
<link href='https://fonts.googleapis.com/css?family=VT323' rel='stylesheet' type='text/css'>
<script src="//code.jquery.com/jquery-1.11.3.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.simpleWeather/3.0.2/jquery.simpleWeather.min.js"></script>
</head>
<body>
<div class="logo">
  <h1>Local Weather App</h1>
</div>

<div class="city">
  <!-- City-->
</div>

<div class="state">
</div>

<div class="weather">
  <!-- Temperature will go here -->
</div>

</body>

</html>


And here is the jQuery..

$.getJSON('http://ip-api.com/json', function(locationIp) {
$.getJSON('http://api.openweathermap.org/data/2.5/weather?lat=' +    locationIp.lat + '&lon' + locationIp.lon, function(weatherDisplay){
$(".city").text(locationIp.city + ',');
$(".state").text(locationIp.region);
$(".weather").text(weatherDisplay.weather.temp);
});
});

    
asked Sep 7, 2015 by rajesh
0 votes
7 views



Related Hot Questions



Government Jobs Opening


...