I'm trying to call a JSON API response and can't seem to displace the response on my website. Can anyone help me figure out what I'm doing wrong?
Updated:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script>
$(document).ready(function(){
$.getJSON("http://localhost:8080/animal/farm", function(data) {
alert("hi");alert(data.data.writeLatencyMicro);
alert(data.farm.horses);
$("ConPerSec").html(JSON.stringify(data));
});
});
</script>
...html
<div id="ConPerSec">
</div>
....
The JSON file comes back as {"farm":{"horses":"2", "cows":"5"}}
<div id="mydiv">and then the jQuery$("#mydiv").html(JSON.stringify(data))unless your intent was to update multiple items on your page that had the class 'ConPerSec'