Reputation: 463
I want to pass value from my controller's function to be processed in view as a chart. But I had a problem with passing the value data.
I've tried to pass the data but it returns null.
Here it is the data that i want to pass through view :
0: {total: "12", person: "[email protected]", activity: "Request Config Files"} activity: "Request Config Files" person: "[email protected]" total: "12"
and this is my view:
$("#btn_ixt_filter").click(function(){
// get_ixt_report("<?php echo base_url();?>index.php/Dashboard/ict_report/" + star_date + "-" + end_date);
$.ajax({
url:"<?php echo base_url(); ?>Dashboard/ict_report/" + star_date +"-"+ end_date,
method: "POST",
dataType : "json",
data: {
'category' : $("#categoryField").val(),
'selection': $("#selectionField").val(),
'counter' : $("#counterField").val(),
'group_by' : $("#groupbyField").val(),
'userid' : $("#useridField").val(),
'role' : $("#roleField").val(),
'customer' : $("#customerField").val(),
'project' : $("#projectField").val(),
'combiner' : $("#combinerField").val(),
},
success:function(data){
$('#result').html(data);
$total.html(total_ticket);
$activity.html(activity);
}
})
event.preventDefault();
The question is how to get these data, total, person, and activity. Thanks
Upvotes: 0
Views: 345
Reputation: 487
url:"<?php echo base_url(); ?>Dashboard/ict_report/" + star_date +"-"+ end_date,
so at your ict_report method .. you have all post data and 2 parameter as start date and end date .... with help of it get data from db ... and the resulted array ... merge all array into one ... and echo the result as json_encoded ...
and at you js ... parse you json_encoded data...
var data = JSON.parse( data );
console.log(data.arrayKey);
Upvotes: 1