title: AJAX request failing to be recognized as POST by PHP script
body: <p>I am trying to post a form to a PHP script, and it is getting stuck at validating the request as a POST request, and thus it exits from the PHP script. The AJAX request returns as successful, but the data returned from the database says the recognition of the request as POST failed. I've tried changing the content types etc, to no avail.</p>
  
  <p>JS:</p>
  
  <pre><code>$(document).ready(function() {
  
      $("#delete4").on('click', function(e) {
          e.preventDefault();
          var ok = confirm('Are you sure you want to delete this?');
          if (ok == true)
          {
              console.log("true")
              var data = $("#form4").serialize();
              $.ajax({
                       data: data,
                       type: "post",
                       url: "delete_AJAX.php",
                       success: function(data) {
                          console.log("successfully deleted");
                          console.log(data);
                          //$("#div4").remove();
                       },
                       error: function(data) {
                            alert("fail");
                            console.log(data);
                        }
              });
          } else {
              return;
          }
      }); 
  });
  </code></pre>
  
  <p>HTML:</p>
  
  <pre><code>&lt;form type="text" name="form4" id="form4" action="delete_AJAX.php" method="post"&gt;
      &lt;div class="aligner"&gt;
          &lt;button type="button" class="button_div" name="edit" onclick="send(52)"&gt;Edit&lt;/button&gt;
          &lt;button type="button" class="button_div" id="delete4"&gt;Delete&lt;/button&gt;
          &lt;button type="button" class="button_div" name="read" onclick="send2(52, 13)"&gt;See&lt;/button&gt;
      &lt;/div&gt;&lt;br&gt;
      &lt;input type="hidden" id="hidden_c4" value="13" name="hidden_c"&gt;
      &lt;input type="hidden" id="hidden_bid4" name="hidden_bid" value="52"&gt;
  &lt;/form&gt; 
  </code></pre>
  
  <p>PHP:</p>
  
  <pre><code>require_once("db.php");
  if ($_REQUEST['REQUEST_METHOD'] === 'POST')
  {
  
      $bid = $_POST['hidden_bid'];
      echo "passed request";
  
      $sql = "SELECT * FROM xxx WHERE yyy = $bid";
      $result = mysqli_query($connection, $sql);
      if ($result === false)
      {
          die("f1");
      }
      $resultCheck = mysqli_num_rows($result);
      if (!resultCheck &gt; 0)
      {
          echo "ERROR NO RESULT";
          exit();
      };
      $row = mysqli_fetch_assoc($result);
      $delete_cover = $row['cover'];
      unlink($delete_cover);
  
  
  
      // updating table row
      $sql2 = "DELETE FROM xxx WHERE (yyy=?);";
                  $stmt = mysqli_stmt_init($connection);
                  if (!mysqli_stmt_prepare($stmt, $sql2))
                  {
                      header("Location: ../create.php?error&amp;prepare1111");
                      exit();
                  }
                  else
                  { 
                      $stmt-&gt;bind_param("i", $bid);
                      mysqli_stmt_execute($stmt);
                      mysqli_stmt_close($stmt);
                      $connection-&gt;close();
                      echo "successfully deleted";
                  }
  
  } else {
      echo "FAILURE TO REQUEST";
  }           
  </code></pre>
  
  <p>So I keep consistently getting failure "FAILURE TO REQUEST", and when I remove any barrier to the script, post is shown as empty, and the variables arent set. Thus it stops at the "f1" error. Any help would be amazing!! Thankyou!</p>