JSON.stringify() displays content in JSON format.I would like the quote in quote class and character in character class.So that on click of button i'll get message and quote displayed.
//HTML
<div class="container-fluid">
<div class = "row text-center">
<h2>GOT Quotes</h2>
</div>
<div class = "row text-center">
<div class = "col-xs-12 well quote">
The message will go here
<br>
<div class = "col-xs-12 well character">
Said By
</div>
</div>
</div>
<div class = "row text-center">
<div class = "col-xs-12">
<button id = "getMessage" class = "btn btn-primary">
Get Message
</button>
</div>
</div>
</div>
//JS
<script>$(document).ready(function () {
$('#getMessage').click(function () {
$.getJSON('https://got-quotes.herokuapp.com/quotes', function (json) {
$('.quote').html(JSON.stringify(json));
});
});
});
jsonparameter is misnamed because it contains an object, not JSON. There is no reason to useJSON.stringify()to turn it back into JSON, just access the properties you need directly. For help with this you'll need to show a sample of the actual JSON structure.