Created
December 16, 2013 14:59
-
-
Save IshamMohamed/7988358 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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