I'm going crazy and hope someone can help. I have an array that I am accessing with Jquery using the getJson function.
I am trying to figure out how I can access and use the variables within the json object. I want to use the variables with a javascript plugin called justgage.
Here is my array on my_url.php
<?php
$my_data=array(min=>"100",max=>"200", total=>"50");
// sending output
header('Content-Type: text/json');
echo json_encode($my_data,true);
?>
Here is my code that gets the array
<script>
$(document).ready(function(){
$("button").click(function(){
$.getJSON("my_url.php",function(result){
$.each(result, function(key, value){
$("#showdata").append(key+value);
});
});
});
});
</script>
Which gives me
min100max200total50
I want to know how to get this data into the variables needed by the justgage script below?
<script>
var g = new JustGage({
id: "gauge",
value: total,
min: 0,
max: 100,
title: "Sample Data"
});
</script>
<script>
$(document).ready(function(){
$("button").click(function(){
$.getJSON("my_url.php",function(result){
var g = new JustGage({
id: "gauge",
value: result.total,
min: result.min,
max: result.max,
title: "Sample Data"
});
});
});
});
</script>