【发布时间】:2012-12-11 10:11:54
【问题描述】:
我正在尝试将此 JSON url 中的数据写出到 li 中。
JSON 链接是https://www.inquicker.com/facility/americas-family-doctors.json
<!DOCTYPE html>
<html>
<head>
<title>JQuery (cross-domain) JSONP</title>
<script type="text/javascript"src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"> </script>
<script>
$(document).ready(function(){
$.getJSON('https://www.inquicker.com/facility/americas-family-doctors.json',
function(data){
alert(data.facility);
$.each(data.schedules, function(i, name){
$('#names').append('<li>' + name.available_times[0] + '</li>');
});
});
});
</script>
</head>
<body>
<ul id="names"></ul>
</body>
</html>
【问题讨论】:
-
您遇到了什么问题?
-
目前这是写出未定义和对象对象。未定义是因为没有任何可用时间,而对象对象是可用时间。我需要能够将 JSON 文件的内容写入列表元素。
标签: javascript json jsonp