Just recently started learning Javascript and read alot about JSON and its benefits.I am doing my own little project and would like to receive help. I want to take JSON values into javascript code but it's not working. I have tried parsing it with this : var obj = JSON.parse(txt);
but that didn't work. Below is my code that better demonstrates my problem.
<body >
<h1> person2</h1>
<div class="koko">
<div id="hh1" class="oee"></div>
<div id="hh2" class="gauge" data-value=" // here the value of json "></div><br>
<div id="gg3" class="gauge"></div><br>
<div id="hh4" class="gauge"></div>
</div>
<script src="raphael-2.1.4.min.js"></script>
<script src="justgage.js"></script>
<script>
document.addEventListener("DOMContentLoaded", function(event) {
var dflt = {
min: 0,
max: 100,
// donut: true,
gaugeWidthScale: 1.1,
counter: true,
hideInnerShadow: true
}
var hh1 = new JustGage({
id: 'hh1',
value: , // here the value of json
title: 'Kalle ',
defaults: dflt
});
var hh2 = new JustGage({
id: 'hh2',
title: 'Pekka',
defaults: dflt
});
var hh3 = new JustGage({
id: 'hh3',
value: , // here the value of json
title: 'Jussi',
defaults: dflt
});
var hh4 = new JustGage({
id: 'hh4',
value: , // here the value of json for Simba
title: 'Simba',
defaults: dflt
});
});
</script>
</body>
values= '{"Kalle" : 75, "Pekka" : 59, "Jussi" : 8, "Simba" : 95}';