I basically read some sensor data and this data gets written to a JSON file. I'm trying to show these readings on a web page but I have as good as no previous experience with jQuery. My measurements.json file contains exactly the same as the commented output var. However when i use the commented line it works. But it does not work when i run the code like here;
<script type="text/javascript">
jQuery(document).ready(function(){
$("#json").load('measurements.json');
//var output = jQuery.parseJSON('{"timestamp": 1391524099.334835, "pH": 1.4132352941176471, "Temperature": -14.934640522815688, "Chlorine": 999.0},');
var output = jQuery.parseJSON("#json");
$('#celc').append(String(output.Temperature));
$('#cl').append(output.Chlorine);
$('#ph').append(output.pH);
});
</script>
<div id="json"><strong>JSON</strong>: </div>
<div id="celc"><strong>Temperatuur</strong>: </div>
<div id="cl"><strong>Chloor</strong>: </div>
<div id="ph"><strong>Zuur</strong>: </div>
Im probably doing something obvious wrong but i cant seem to figure it out using just Google.
Thanks!