【发布时间】:2017-11-18 00:43:54
【问题描述】:
我正在尝试使用来自 api 的 JSON 来生成随机引号。单击按钮时,json 应填充以代替“消息将转到此处”。但我发现卡住了。代码如下和项目链接:
https://codepen.io/monsieurshiva/pen/awBbEE
<html>
<head>
<script>
$(document).ready(function() {
$("#getMessage").on("click", function(){
$.getJSON("http://api.forismatic.com/api/1.0/?method=getQuote&format=json&lang=en", function(json) {
$(".message").html(JSON.stringify(json));
});
});
});
</script>
</head>
<body>
<div class = "col-xs-12 well message">
The message will go here
</div>
<button id = "getMessage" class = "btn btn-primary">
Get Message
</button>
</body>
</html>
【问题讨论】: