I am getting these values from my json in my console: Object {test: 0, howmuch: 0, day: 22, calls: Array[0]}
But how can I print this on my html? I tried doing jquery but I could not get. As well will be simple for me get these values from a url?
jquery:
$(document).ready(function () {
$('#get-data').click(function () {
var showData = $('#show-data');
$.getJSON('real-data.json', function (data) {
console.log(data);
alert(data);
showData.empty();
});
showData.text('Loading the JSON file.');
});
});
json:
{
"test": 0,
"howmuch": 0,
"day": 22,
"calls": [
]
}
html:
<!DOCTYPE html>
<html>
<head>
<script data-require="[email protected]" data-semver="1.9.1" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0-rc1/jquery.min.js"></script>
<script src="real-data.js"></script>
<style>body{ background: #F9F9FA; }</style>
</head>
<body>
<a href="#" id="get-data">Get JSON data</a>
<div id="show-data"></div>
</body>
</html>
JSON.stringify. But presumably you'd prefer to format it to look better than that. But you need to decide how you want it to appear and then append html elements to achieve that.