0

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

2
  • can you post full json ouput here or as a link on pastebin what you have posted isn't valid; also think about including your php code? thanks Commented Jan 8, 2019 at 4:07
  • Your question is not clear, Are you asking how to print properly what you got on ajax call or passing data using ajax? Commented Jan 8, 2019 at 6:34

1 Answer 1

1
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);
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.