APIからJSONを使用してランダムな引用符を生成しようとしています。ボタンをクリックすると、「メッセージはここに行きます」の代わりにjsonが入力されます。しかし、私は立ち往生しています。コードは以下の通りですし、プロジェクトのリンク:jQuery getJSONメソッドで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>
私はそのためのクロスドメインエラーと思いますか? – AdhershMNair
jsonオブジェクトの見積もりを読んでから、その見積もりをdivに追加すると、jsonオブジェクトを読むときにこの[チュートリアル](https://www.w3schools.com/js/js_json_objects.asp)をチェックし、 allow](https://stackoverflow.com/questions/6871021/how-to-enable-cross-domain-request-on-the-server)クロスドメインajaxコール – Munzer
https://j11y.io/javascript/cross -domain-requests-with-jquery / – Freak