I’m trying to get JSON file with ajax and display it in an HTML div but only part of it, not everything.
Here is the ajax
$(function () {
$.ajax({
'url': 'http://apis.is/weather/observations/en?stations=3696&time=1h&anytime=0',
'type': 'GET',
'dataType': 'json',
'success': function(response) {
}
});
});
and I’m trying to put just some object for example just the temperature in the HTML div
<!DOCTYPE html>
<html lang="is" dir="ltr">
<head>
<meta charset="utf-8">
<title></title>
<script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
<script src="js/main.js"></script>
</head>
<body>
<div id="result">
<p>i want the result here</p>
</div>
</body>
</html>
anybody that knows this stuff?
2
Answers
You can start from here, I displayed the whole object but you need to parse the data according to your needs
Consider the following code.
This takes the JSON Data, converts it into a String, and adds it to the
<p>
.