title: using .each to loop through Json Response
body: <p>I'm trying to loop through a json object with .each(), but I'm struggling with getting the syntax right. </p>
  
  <p>Ajax Call, which results in "undefined": </p>
  
  <pre><code>$('.showGroup a').on('click', function(e) {
  e.preventDefault();
      var _href = $(this).attr("href");
       $.ajax({
         dataType: 'json',
         url : _href,
         type : 'GET',
         success : function(response) {
            $("#replace").empty();
            display = response;
          $.each(display, function(i, member) {
              alert(display[i].company_name);
          });
       },
      error : function() {
          console.log('error');
      }
    });
  });
  </code></pre>
  
  <p>if I just call alert(display[i]);  my json object looks like this:</p>
  
  <pre><code>{"total":134,"per_page":15,"current_page":1,"last_page":9,"from":1,"to":15,"data":[{"id":"89","company_name":"test" ...
  </code></pre>
  
  <p>I have also tried to nest another .each() loop, but I get the response: Uncaught TypeError: Cannot use 'in' operator to search for '17381'</p>
  
  <p>I have looked through several SO answers and tried various styles of .each loops, but I always get an undefined error. </p>
  
  <p>What am I missing?</p>
  
  <p><strong>EDIT</strong>
  I am constructing json like this on backend: </p>
  
  <pre><code>$members = $this-&gt;user-&gt;getMemberIds($loggedIn-&gt;id, $display, $associationFilter);
             $this-&gt;arrResponse['members'] = $members-&gt;toJson();
  return Response::json($this-&gt;arrResponse);
  </code></pre>