title: Echo array values which requested with ajax
body: <p>I am trying to send with ajax the values of the buttons the user have clicked. After the user clicked a button the ajax should send a request with the updated array values. If I run <code>var_dump($buttons);</code> I get <code>NULL</code>. Before that I added <code>$buttons = $_POST['buttons'];</code> to get the array, but it wont work. Why get I showed <code>NULL</code> and not the array?</p>
  
  <p><strong>my console:</strong> <code>Yay it worked ["1", "4"]</code></p>
  
  <p><strong>my javascript:</strong></p>
  
  <pre><code>    var values = [];
  
  jQuery(document).ready(function($){
  
      $('.ui-btn').click(function() {
          values.push($(this).val());
          $.ajax({
              url: 'gamescreen.php',
              type: 'post',
              data: {
                  buttons: values,
              },
              success: function() {
                 console.log('Yay it worked', values);
              },
              error: function() {
                 console.log('Something went wrong');
              }
          });
      });
  });
  </code></pre>
  
  <p><strong>my html:</strong></p>
  
  <pre><code> &lt;div&gt;
      &lt;button name="btn1" type="submit" id="btn1" value="1" class="ui-btn"&gt;&lt;/button&gt;
      &lt;button name="btn2" type="submit" id="btn2" value="2" class="ui-btn"&gt;&lt;/button&gt;
      &lt;/div&gt; // I have up to 9 buttons, thats only a piece
  </code></pre>
  
  <p><strong>my php code:</strong></p>
  
  <pre><code>$buttons = $_POST['buttons'];
  var_dump($buttons);
  </code></pre>