title: Can't access the json values in my ajax success in codeigniter
body: <p>now guys i know this is a simple error but no matter what i try i cant access the json values whenever i use alert after parse json it shows me undefined 
  why is it caused ?
  here is my code 
  script</p>
  
  <pre><code>function getfriend_requests()
  {
  var id=$('.id_data').attr('value');
  
  jQuery.ajax({
                  type:'POST',
                  url:'&lt;?php echo base_url("user/getallfriends"); ?&gt;',
                  data:{id:id},
                  dataType:'json',
                  success:function(data)
                  {   
  
                       var ParsedObject = JSON.stringify(data);            
                       var json = $.parseJSON(ParsedObject);
                       alert(json);
                       $.each(json,function(key,data)
                    {
                        alert(data.object);
                    });
              }
              });
  }
  </code></pre>
  
  <p>now the controller </p>
  
  <pre><code>public function getallfriends()
  {
    $id=$this-&gt;input-&gt;post('id');
    $this-&gt;load-&gt;model('Pmodel');
    $data['senders']=$this-&gt;Pmodel-&gt;get_all_user_friends_sender($id);
  
  
    $data['recievers']=$this-&gt;Pmodel-&gt;get_all_user_friends_reciever($id);
  
    echo json_encode($data);
  }
  </code></pre>
  
  <p>now the model</p>
  
  <pre><code>public function get_all_user_friends_sender($id)
  {
  
  
       $this-&gt;db-&gt;select('*');
       $this-&gt;db-&gt;from('user_friend');
       $this-&gt;db-&gt;join('user_data', 'user_friend.senders_id = user_data.id');
       $this-&gt;db-&gt;join('user', 'user_friend.senders_id = user.id');
       $this-&gt;db-&gt;where('user_friend.senders_id',$id);
  
      $query = $this-&gt;db-&gt;get();
  
  
  
          $row = $query-&gt;result_array();
       // print_r($row);
          return($row);
  
  
  
  }
  public function get_all_user_friends_reciever($id)
  {
  
       $this-&gt;db-&gt;select('*');
       $this-&gt;db-&gt;from('user_friend');
       $this-&gt;db-&gt;join('user_data', 'user_friend.recievers_id = user_data.id');
       $this-&gt;db-&gt;join('user', 'user_friend.recievers_id = user.id');
       $this-&gt;db-&gt;where('user_friend.recievers_id',$id);
  
      $query = $this-&gt;db-&gt;get();
  
          $row = $query-&gt;result_array();
       // print_r($row);
          return($row);
  
  
  
  }
  </code></pre>
  
  <p>now when i try to return the value with result_array iy shows me undefined value but if i use $row_array it return only single value from each model.
  can you tell me where i am going wrong?
  <a href="https://i.stack.imgur.com/nHhU2.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nHhU2.png" alt="response"></a><a href="https://i.stack.imgur.com/FS635.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FS635.png" alt="enter image description here"></a></p>