stored in database.I am working in codeignitor framework. It is a php framework.
I have written code to get data from database.
function getCountJSON($first_tbl, $first_tbl_field, $second_tbl, $second_tbl_field) {
$result = $this->gm->getQueryCount($first_tbl, $first_tbl_field, $second_tbl, $second_tbl_field);
$result_array = array();
foreach ($result as $r) {
$result_array[] = array('country' => $r['country_name'], 'count' => $r['query_count']);
}
echo json_encode($result_array);
}
Now I need to get my JSON Object by using ajax request. I used following code snippet to get data from ajax request.AmCharts.loadJSON = function (url) {
// create the request
if (window.XMLHttpRequest) {
// IE7+, Firefox, Chrome, Opera, Safari
var request = new XMLHttpRequest();
} else {
// code for IE6, IE5
var request = new ActiveXObject('Microsoft.XMLHTTP');
}
// load it
// the last "false" parameter ensures that our code will wait before the
// data is loaded
request.open('POST', url, false);
request.send();
// parse and return the output
return eval(request.responseText);
/> };
I have taken the JSON object to javascript variable.var chartData1 = AmCharts.loadJSON("ajax/getCountJSON/countries/country_name/customers/country_id");
I Got following Result in amchart.Thank you !



0 comments:
Post a Comment
Ask anything about this Tutorial.