title: Sending array to controller/model in CI with AJAX
body: <p>So basically I have a two item array in javascript that is generated based on which link the user clicks. I am trying to send this array to my controller, and then to the model. The model will look at the array and match one of the items to a certain column/row, and will selectively display data.</p>
  
  <p>I am having issues passing the data from AJAX to my controller.</p>
  
  <p>AJAX code (in a .js file)</p>
  
  <pre><code>  $('#youmax-video-list-div').append('&lt;div id="testing1"&gt;&lt;/div&gt;');
  
                      $('#concept').click(function(){
                                          console.log(course);
                         $.ajax({
                                url: 'http://localhost:8888/index.php/trial/getValues',
                                type:'POST',
                                dataType: 'json',
                                data:'',
                                error: function(){
                                $('#testing1').append('&lt;p&gt;goodbye world&lt;/p&gt;');
                                },
                                success: function(result) {
                                var htmlStr = '';
                                $.each(result, function(a, b){
                                       htmlStr += b.qText + '&lt;br /&gt;';
                                       });
                                $('#testing1').append(htmlStr);
                                } // End of success function of ajax form
                                }); // End of ajax call
                         });
  </code></pre>
  
  <p>I am assuming I must do something with the data field, but I dont know the syntax for it. </p>
  
  <p>The console log in chrome comes up with this:</p>
  
  <p>Array[2]
  0: "PL8G0kdHFfE3WuyevUDvwSYCZw8mp8LBFA"
  1: "PL8G0kdHFfE3V62Jp2ju-PelOaNUkH7xR8"</p>
  
  <p>Controller</p>
  
  <pre><code>function getValues(){
      $this-&gt;load-&gt;model('get_db');
      $data = $this-&gt;get_db-&gt;getAll();
      $this-&gt;output-&gt;set_content_type('application/json');
      $this-&gt;output-&gt;set_output(json_encode($data));
      return $data;  
  }
  </code></pre>
  
  <p>Model</p>
  
  <pre><code>class Get_db extends CI_Model{
      function getAll(){
          $query=$this-&gt;db-&gt;query("SELECT * FROM questions");
          return $query-&gt;result();
          //returns from this string in the db, converts it into an array
  
      }
  }
  </code></pre>
  
  <p>As I said before, I am really only concerned with getting the data to my controller and my model.
  The name of the array is "course". However, that doesnt appear to be so in the console.log. Is that just something chrome does?</p>