title: Error on PHP Form with json decode after AJAX Request
body: <p>After much research and confusion I've decided to ask on here.</p>
  
  <p>Basically, I can make my AJAX request post in every way except JSON. I'd like to learn it so I can just start from JSON instead of learning it down the road. </p>
  
  <p>The <strong>PHP code</strong> below errors </p>
  
  <blockquote>
    <p>Undefined index: data</p>
  </blockquote>
  
  <p>What am I missing?</p>
  
  <p>Here's the <strong>.serializeArray() &amp; JSON Stringyfied</strong> console string:</p>
  
  <pre><code>[
      {
          "name" : "client_id",
          "value" : "111"
      }, {
          "name" : "project_id",
          "value" : "222"
      }, {
          "name" : "user_id",
          "value" : "465605"
      }, {
          "name" : "utl_latitude",
          "value" : "40.6110589"
      },{ 
          "name":"utl_longitude",
          "value":"-111.8999353"
      },{
          "name" : "utl_event",
          "value":"CLOCK IN"
      }, {
          "name" : "utl_action",
          "value" : "FOLLOW UP"
      }
  ]
  </code></pre>
  
  <p>The <strong>AJAX request</strong> to the best of my knowledge</p>
  
  <pre><code>// START AJAX REQUEST ---------------------------------------------------------------------------        
  $.ajax({
  
      url: 'test.php',
      method: 'POST',
      dataType: 'json',
      data: url_parameters,
      //contentType: "application/json; charset=utf-8",
      timeout: 5000, // Longer than 5 seconds? HTTP SERVER or PHP Offline.***
  
      beforeSend: function () {
  
          self.status_please_wait();
  
      },
  
      success: function (data, textStatus, jqXHR) {
  
          /* PHP PDO MySQL Insert Status --------------------------------------------------
  
          return 0 = Nothing to Update (***Disable for Select &amp; Insert)
          return 1 = Successful Insert Query
          return 2 = Database Connection refused
          return 3 = MySQL Query Error OR Wrong URL Parameters */
  
          // ----------------------------------------------------------------------------
  
          // If data return 0 = Nothing to Update
          // Placeholder for future mysql Update
  
          // ----------------------------------------------------------------------------
          // If data return 1 = Successful Insert Query
          if (textStatus === 'success' &amp;&amp; data === '1') {
  
              //self.php_pdo_mysql_insert_status(data);
  
              self.status_insert_success();
  
          }
  
          // ----------------------------------------------------------------------------
          // If data return 2 = Database Connection refused
          if (textStatus === 'success' &amp;&amp; data === '2') {
  
              //self.php_pdo_mysql_insert_status(data);
  
              self.status_mysql_connection_refused();
  
          }
  
          // ----------------------------------------------------------------------------
          // If data return 3 = MySQL Query Error OR Wrong URL Parameters
          // Placeholder for future mysql error 3
  
          // ----------------------------------------------------------------------------
  
      },
      // END SUCCESS function ---------------------------------------------------------
  
      error: function (jqXHR, textStatus, errorThrown) {
              // NIGX offline or PHP offline.
  
              // If http server and/or PHP is/are offline...
              if (errorThrown === 'timeout') {
  
                  self.status_http_php_offline();
  
              }
  
  
          }
          // END ERROR function ---------------------------------------------------------
  
  });
  // END AJAX REQUEST -----------------------------------------------------------------------------
  </code></pre>
  
  <p><strong>The PHP on the server side:</strong></p>
  
  <pre><code>&lt;?php
  
      $decoded = json_decode($_POST['data'],true);
  
      foreach ($decoded as $value) {
         echo $value["name"] . "=" . $value["value"];
      }
  
  ?&gt;
  </code></pre>
  
  <p><strong>The PHP error</strong></p>
  
  <blockquote>
    <p><br />
        <b>Notice</b>:  Undefined index: data in <b>F:\Wnmp\html\mysql_post_json\test.php</b> on line <b>9</b><br />
        <br />
        <b>Warning</b>:  Invalid argument supplied for foreach() in <b>F:\Wnmp\html\mysql_post_json\test.php</b> on line <b>11</b><br /></p>
  </blockquote>