Skip to content

Instantly share code, notes, and snippets.

@IshamMohamed
Created December 16, 2013 14:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IshamMohamed/7988358 to your computer and use it in GitHub Desktop.
Save IshamMohamed/7988358 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.2/jquery.min.js"></script>
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<body>
<button onclick="getWeather(31.12819929911196,84.55078125,function (data) {
console.log('weather data received');
console.log(data.list[0].weather[0].description);
alert(data.list[0].weather[0].description);
});"/>get weather</button>
</body>
</html>
function getWeather(lat,lang,callback) {
var weather = 'http://openweathermap.org/data/2.1/find/city?lat='+lat+'&lon='+lang+'&cnt=10';
$.ajax({
dataType: "jsonp",
url: weather,
success: callback
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment