【发布时间】:2021-06-24 23:47:52
【问题描述】:
我正在尝试使用 ajax 获取 JSON 文件并将其显示在 HTML div 中,但只是其中的一部分,而不是全部。
这里是ajax
$(function () {
$.ajax({
'url': 'http://apis.is/weather/observations/en?stations=3696&time=1h&anytime=0',
'type': 'GET',
'dataType': 'json',
'success': function(response) {
}
});
});
我正在尝试仅放置一些对象,例如 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>
有人知道这些吗?
【问题讨论】:
-
欢迎来到 Stack Overflow。您尚未提供将发送回 AJAX 调用的 JSON 数据示例。您希望显示哪些具体细节?请提供一个最小的、可重现的示例:stackoverflow.com/help/minimal-reproducible-example
-
嗨 Magnús,不鼓励在 StackOverflow 上提出纯代码问题。如果您还没有,您应该take the tour 并熟悉how to ask a good question。谢谢!
标签: javascript html jquery json ajax