Welcome Guest, Not a member yet? Register   Sign In
how to call function in different module?
#4

(This post was last modified: 01-21-2018, 10:10 PM by richb201.)

Hey Dave! This is how I am trying to get my json data over from my controller to my view file called configure_chart.php.
       $this->load->view('configure_chart');
       $this->output->set_content_type('application/json', 'utf-8');
       $this->output->set_output(file_get_contents("sampleData.json"));
Instead of loading the library package and then setting up the callback (see below), this code just prints the HTML of configure_chart.php (un rendered) to the browser window. Any ideas on why the browser is not rendering the HTML? Is it something obvious? I am hampered by the inability of phpStorm/xDebug to allow me to debug javascript code. I am flying blind. 

this is the script inside of configure_chart.php

  <script>
       google.charts.load('current', {packages: ['corechart']});
       google.charts.setOnLoadCallback(drawChart);

   function drawChart() {
       var jsonData = $.ajax({
           url: "/Configure.php/org_chart_management",
           dataType: "json",
           async: false
       }).responseText;

       var data = new google.visualization.DataTable(jsonData);

       // Create the chart.
       // Instantiate and draw our chart, passing in some options
       var chart = new google.visualization.OrgChart(document.getElementById('chart_div'));
       // Draw the chart, setting the allowHtml option to true for the tooltips.
       chart.draw(data, {allowHtml: true});
   }
   </script>

The other thing is I am using ajax as you can see above to pass my json data from php to javascript. But in
https://www.codeigniter.com/user_guide/g...ting-loops
They are just loading a view  with the data attached:
$this->load->view('blogview', $data); to transfer an array from PHP to javascript. 
Which is the right way to do it? 

Attached Files Thumbnail(s)
   
proof that an old dog can learn new tricks
Reply


Messages In This Thread
RE: how to call function in different module? - by richb201 - 01-21-2018, 10:00 PM



Theme © iAndrew 2016 - Forum software by © MyBB