title: Multiple Arrays returned by json from PHP
body: <p>To begin with I am building a complete CRM running Ajax and there is a lot to this, so please be patient and read the whole thing. </p>
  
  <p>I have an ajax script returning several json arrays. When I display the return value from my php script I get this:</p>
  
  <pre><code>[{"packages":{"id":"1","name":"Land Line"}},{"packages":{"id":"2","name":"Cellular w\/Alarm.com"}},{"packages":{"id":"3","name":"Home Automation"}}]
  </code></pre>
  
  <p>What I am trying to do is separate the arrays so I can make a select drop down from it. Before anyone says anything, yes I know how to do that my itself, but I am needing the form this script is populating to be a select dropdown or a complete filled in form based off of the id going into another script. It is a bit confusing, so don't ding me for it please.</p>
  
  <p>Here is the PHP script alliance_form.php:</p>
  
  <pre><code>    $equip = "SELECT * FROM packages WHERE brand='$brand'";
      if($db-&gt;query($equip) === false)    {
          trigger_error('Wrong SQL: ' . $query . ' Error: ' . $db-&gt;error, E_USER_ERROR);
      } else  {
          $result = $db-&gt;query($equip);
          $array = array();
          foreach($result as $r)  {
              $array[] = array(
                      "packages" =&gt; array(
                      "id" =&gt; $r['id'],
                      "name" =&gt; $r['name']
                      )
              );
          }
          echo json_encode($array);
      }
  </code></pre>
  
  <p>Here is the jquery going to the PHP form and coming back to input the information:</p>
  
  <pre><code>$.ajax({
      type: "POST",
      url: "/crm/alliance_form.php",
      data: dataString,
      success: function(msg)
          {
              $("#package-form").html(msg);
              $.each(msg.packages, function(i, object)    {
                  $.each(object, function(index, value) {
                      alert(value);
                  });
              });
  
          },
      error: function(error)
          {
              $(".error").html(error);
          }
  }); 
  </code></pre>
  
  <p>This is part of an ordering system of a CRM, so this script is checking the database for existing orders under the id. If the id is there then it is supposed to come back with the order information and I populate the form. If not it will give a select dropdown to select a package which then populates an empty form. That is the gist of what I am on right now. </p>
  
  <p>Here is the question: Why can't I get a response from JQuery on the each() loop on this. One return comes back with a regular array, and this one is a nested array.</p>