我想从 iheartquotes 获取报价,并在页面加载时将其添加到 div 中。我目前有此代码,但不知道为什么它不起作用
<script type="text/javascript">
$(document).ready(function() {
$.getJSON('http://iheartquotes.com/api/v1/random?format=json&callback=?', function(data) {
$(".content").html(json.quote);
});
});
</script>
和正文中的 HTML
<div class="content">
This will be replaced with a quote
</div>