title: Error when passing a array to a JavaScript function
body: <p>Please refer the following code. 
  I am trying to pass an array to a JavaScript function.</p>
  
  <pre><code>&lt;?PHP
     function controller_function(){
        $data['batch_id'] = $this-&gt;input-&gt;post('batch_id');
  
        echo json_encode($this-&gt;Student_model-&gt;load_student_data($data));
     }
  ?&gt;
  
  
  //In JS
  function load_data() {
      $.post("&lt;?php echo base_url('contoller/controller_function') ?&gt;", {'batch_id': batch_id}
          function (data)
          {
              for (j = 0; j &lt; data.length; j++) {
              view_data(data[j]);
              }
          },
          "json"
      );
  }
  
  function view_data(data_array) {
      alert(data_array)
  }
  </code></pre>
  
  <p>Like above when i try to alert out the <code>data_array</code>, the error <code>Uncaught SyntaxError: Unexpected identifier</code> shows.</p>
  
  <p>Below is the <code>data[j]</code> array.</p>
  
  <pre><code>Array
          (
              [stu_id] =&gt; 1
              [name] =&gt; abc
              [applied_courses] =&gt; Array
                  (
                      [0] =&gt; Array
                          (
                              [id] =&gt; 1
                              [course_id] =&gt; 1
                          )
  
                      [1] =&gt; Array
                          (
                              [id] =&gt; 2
                              [course_id] =&gt; 2
                          )
  
                  )
  </code></pre>
  
  <p>Please help me on this.</p>