I am newbie with javascript and jquery and i am facing a problem in json parsing with jquery. I am using open weather simplest API for fetching the weather information but nothing is happening. If i hardcode the json in any file or in my script it works fine but as soon as i use URL of API it stop showing result.
here is my complete code:
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script>
function myFunction() {
var path = "api.openweathermap.org/data/2.5/weather?q=Lahore,pk";
$(document).ready(function () {
$("button").click(function () {
$.getJSON(path, function (data) {
$.each(result, function (i, field) {
$("div").append(field + " ");
});
});
});
});
}
</script>
</head>
<body>
<button onclick="myFunction()">Get JSON data</button>
<div></div>
</body>
</html>
result. Where is it's definition ?http://at the start ofpath. But does that website support CORS or JSONP? You should check your console for errors. Very important when debugging Javascript