title: Why doesn't the die() function work?
body: <p>I have an ajax call that sends data from a form to a php file that will then insert that data to the database. I put a call to <code>die</code> in said php file because I want to try something but it doesn't work.</p>
  <h3>addUserForm.php</h3>
  <pre><code>&lt;script&gt;
      $(document).ready(function () {
          var $form = $('form');
          $form.submit(function (event) {
              event.preventDefault();
  
              var formData = $form.serialize(),
                  url = $form.attr('action');
  
              $.ajax({
                  type: &quot;POST&quot;,
                  url: url,
                  data: formData,
                  success: function () {
                      //$(&quot;#div1&quot;).load(&quot;table.php&quot;);
                      alert('User Successfully Added');
                      document.getElementById(&quot;form1&quot;).reset();
                  }
              });
          });
      });
  &lt;/script&gt; 
  </code></pre>
  <p>Here is the php file:</p>
  <h3>addUser.php</h3>
  <pre><code>&lt;?php
      include('sqlconnection.php');
      die('here');
      $firstname = $_POST['fname'];
      $lastname = $_POST['lname'];
      $middlename = $_POST['mname'];
      $password = $_POST['pword'];
      $username = $_POST['uname'];
      $gender = $_POST['gender'];
      $utype = $_POST['utype'];
  
      $query = &quot;INSERT INTO user (firstname,lastname,middlename,gender) VALUES ('$firstname','$lastname','$middlename','$gender')&quot;;   
  
      mysqli_query($con,$query);
  
      $result = mysqli_query($con,&quot;SELECT id FROM user WHERE firstname = '$firstname'&quot;);
  
      $row = mysqli_fetch_assoc($result);
  
      $uid=$row['id'];
  
      $result = mysqli_query($con,&quot;INSERT INTO accounts (u_id,username,password,account_type) VALUES ('$uid','$username',md5('$password'),'$utype');&quot;);
  
  ?&gt;
  </code></pre>
  <p>Even when there is a <code>die</code> call in <code>adduser.php</code> it still alerts that the user was successfully added.</p>