title: How to send an JavaScript array to PHP via jQuery.ajax?
body: <p>I'm trying to send a JavaScript array to a PHP page via jQuery.ajax, but the array is sent only with blank values.</p>
  
  <p>If I open the F12 Console on Chrome and check for the JS object, it's there. All filled up. But when I log the PHP variable using the ChromePhp tool, it shows only the blank values (also, if I iterate over the php-array, echoing its values, I get all blanks).</p>
  
  <p>I'm deeply confused here.</p>
  
  <p>Here goes my sample code:</p>
  
  <pre><code>&lt;?php 
  include 'ChromePhp.php';
  if (isset($_GET['newUsers'])) {
      $newUsers = $_GET['newUsers'];
      ChromePhp::log($newUsers);
  } else { ?&gt;
  
  &lt;html&gt;
  &lt;body&gt;
  
      &lt;script src="js/jquery-2.0.3.min.js"&gt;&lt;/script&gt;
      &lt;script type="text/javascript"&gt;
          var newUsers = [];
  
          newUser = [];
          newUser['nome'] = 'alvaro';
          newUser['idade'] = '34';
          newUsers.push(newUser);
  
          newUser1 = [];
          newUser1['nome'] = 'bia';
          newUser1['idade'] = '7';
          newUsers.push(newUser1);
  
          newUser2 = [];
          newUser2['nome'] = 'alice';
          newUser2['idade'] = '2';
          newUsers.push(newUser2);
  
          $.ajax({
              url: "testcookie.php",
              type: "GET",
              data: {
                  'newUsers[]': newUsers
              }
          });
  
      &lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  &lt;?php } ?&gt;
  </code></pre>
  
  <hr>
  
  <p><strong>Updated</strong> Based on the first comments. Now I get to pass the object, but don't know how to read its properties. Already tried $user['nome'] with no result.</p>
  
  <pre><code>&lt;?php 
  include 'ChromePhp.php';
  
  if (isset($_POST['newUsers'])) {
  
      $newUsers = $_POST['newUsers'];
  
      foreach ($newUsers as $user) {
          # code...
          # HOW DO I READ THE nome AND idade VALUES HERE?
      }
  
  } else { ?&gt;
  
  &lt;html&gt;
  &lt;body&gt;
  
      &lt;script src="js/jquery-2.0.3.min.js"&gt;&lt;/script&gt;
      &lt;script type="text/javascript"&gt;
          //var newUsersObj = {};
          var newUsers = [];
  
          newUser = {};
          newUser['nome'] = 'alvaro';
          newUser['idade'] = '34';
          newUsers.push(newUser);
  
          newUser1 = {};
          newUser1['nome'] = 'bia';
          newUser1['idade'] = '7';
          newUsers.push(newUser1);
  
          newUser2 = {};
          newUser2['nome'] = 'alice';
          newUser2['idade'] = '2';
          newUsers.push(newUser2);
  
          $.ajax({
              url: "testcookie.php",
              type: "POST",
              data: {
                  'newUsers[]': newUsers
              },
              success: function () {
  
              },
              error: function () {
  
              }
          });
  
      &lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  &lt;?php } ?&gt;
  </code></pre>