Hi I’m trying to get json from an external website and displaying it on mypage I’ve tried a lot of thing but none of them work, here’s my code:
HTML
<body class = "bodyBackColor">
<div class = "container-fluid">
<div class = "quotes1">
</div>
<button id = "showQuote" class = "btn btn-primary">
show Quote
</button>
</div>
</body>
JAVASCRIPT
$(document).ready(function() {
$("#showQuote").on("click", function () {
//$(".quotes1").html("das");
$.getJSON("www.freecodecamp.com/json/cats.json", function(json) {
//alert("das");
$(".quotes1").html(JSON.stringify(json));
});
});
});
I’ve tried using($.getJSON("www.freecodecamp.com/json/cats.json?callback=?) and nothing, the click function is working, but after the getJSON it doesn’t do anything, I place an alert inside it but never shows, so please tell me what am I doing wrong.
Thanks.