Hi everyone,
I'm sure there are people who are using highCharts framework. I'm having a trouble passing the values to jquery code from PHP json. Your help is so appreciated.
This is my php section
<?php
header('Cache-Control: no-cache, must-revalidate');
header('Expires: Mon, 01 Jan 2013 00:00:00 GMT');
// The JSON standard MIME header.
header('Content-type: text/json');
include('mysql_connector.php');
$port = new MySqlDatabase();
$port->connect('root','','theants');
$query = "select * from userss";
$result = mysql_query($query);
$array = mysql_fetch_assoc($result);
$jsonData = json_encode($array);
echo $jsonData;
?>
This is my jquery section
$.getJSON('ajax.php', function(jsonData){
$.each(jsonData, function(key, value){
chart = new Highcharts.Chart({
chart: {
renderTo: 'container',
type: 'pie'
},
title: {
text: 'User Ages'
},
xAxis: {
categories: ['0-9', '10-19', '20-29', '30-39', '40-49', '50-59', '60-69', '70-79'],
title: {
text: 'Age group'
}
},
tooltip: {
formatter: function() {
return ''+
this.series.name +': '+ this.y +' user(s)';
}
},
plotOptions: {
bar: {
dataLabels: {
enabled: true
}
}
},
legend: {
layout: 'vertical',
align: 'right',
verticalAlign: 'top',
x: -100,
y: 100,
floating: true,
borderWidth: 1,
backgroundColor: '#FFFFFF',
shadow: true
},
series: [{
name: 'No. of Users',
data: []
}]
});
});
}
);
I just want to get the values from the function "function(key,value)" and I am not concerned about the key. Quick example/examples will do for now.