title: Send form inputs with AJAX to PHP
body: <p>I want to send form inputs from a page to a PHP function, using AJAX, and save the data in a multidimensional array. There should be no page reload, and the response can be a simple <code>true</code> or <code>false</code>. In the Chrome browser, I can see both inputs in the "Request Payload" element, in JSON, but how can I retrieve the data in PHP and transform this data into an array? </p>
  
  <p>HTML:</p>
  
  <pre><code>&lt;div id="formEditBilling"&gt;&lt;form&gt;
  &lt;input name="register[personal][firstname]" type="text" id="firstname" value="" class="text required " placeholder="Firstname"&gt;
  &lt;input name="register[personal][lastname]" type="text" id="lastname" value="" class="text required " placeholder="Lastname"&gt;
  &lt;input type="buttom" id="editBilling" value="speichern"/&gt;&lt;/form&gt;&lt;/div&gt;
  </code></pre>
  
  <p>JavaScript:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  
  $('#editBilling').click(function() {
      editBilling();
  });
  
  
  function editBilling(){
  
      var url = '/checkout/saveAddress';  // Server Function
  
      var data = $('#formEditBilling form').serializeArray();
      data = JSON.stringify(data);
  
      $.ajax({
          'type': 'post',
          'async': false,
          'data': data,
          'url': url,
          'contentType': "application/json",
          'dataType': "text",
          'success': function (result, data) {
  
      $('.output').html(data);    // Output Div
   }
  });
  }
  &lt;/script&gt;
  </code></pre>
  
  <p>Here's my problem. How can I get a array like:</p>
  
  <pre><code>['register'] =&gt; Array 
      ( 
          ['personal'] =&gt; Array
                   (
                        ['firstname'] =&gt; "Michael"
                        ['lastname']  =&gt; "Cooper"
  
      )
  </code></pre>
  
  <p>PHP: Here's my attempt, but it's not working, <code>$_POST</code> seems to be empty.</p>
  
  <pre><code>public function saveAddressAction(){
  
      $data = json_decode(stripslashes($_POST['register']));
  
      return true;
  }
  </code></pre>