title: jQuery Ajax form submit error handling
body: <p>I have the following code:</p>
  
  <pre><code>var url = "save.php"; // the script where you handle the form input.   
  
  $.ajax({
          type: "POST",
          url: url,
          data: $("#frmSurvey").serialize(), // serializes the form's elements.
  
          success: function(){
              alert('success');
            },
          error: function(){
              alert( "Request failed: " );
            }
  
          }); 
  </code></pre>
  
  <p>Now, this works fine when submitting data to the DB - however, when I deliberately change the <code>save.php</code> file so that data isn't submitted, I still get the <code>success</code> alert.  </p>
  
  <p>Code for the save file below:</p>
  
  <pre><code>$proc = mysqli_prepare($link, "UPDATE tresults SET ip = ?, browser = ?, q1 = ?, q2 = ?, q3 = ?, q4 = ?, q5 = ?, q6 = ?, q7 = ?, q8 = ?, q9 = ?, q10 = ?, q11 = ?, q12 = ?, q13 = ?, q14 = ?, q15 = ?, q16 = ?, q17 = ?, q18 = ?, q19 = ?, q20 = ?, q21 = ?, q22 = ?, q23 = ?, q24 = ?, q25 = ?, q26 = ?, q27 = ?, q28 = ?, q29 = ?, q30 = ?, q31 = ?, q32 = ?, q33 = ?, q34 = ?, q35 = ?, q36 = ?, q37 = ?, q38 = ?, q39 = ?, q40 = ?, q41 = ?, q42 = ?, q43 = ?, q44 = ?, q45 = ?, q46 = ?, q47 = ?, q48 = ?, q49 = ?, q50 = ?, q51 = ?, q52 = ?, q53 = ?, q54 = ?, q55 = ? WHERE respondent_id = ?;");
      mysqli_stmt_bind_param($proc, "ssiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiissi", $ip, $browser, $q1, $q2, $q3, $q4, $q5, $q6, $q7, $q8, $q9, $q10, $q11, $q12, $q13, $q14, $q15, $q16, $q17, $q18, $q19, $q20, $q21, $q22, $q23, $q24, $q25, $q26, $q27, $q28, $q29, $q30, $q31, $q32, $q33, $q34, $q35, $q36, $q37, $q38, $q39, $q40, $q41, $q42, $q43, $q44, $q45, $q46, $q47, $q48, $q49, $q50, $q51, $q52, $q53, $q54, $q55, $respondent_id);
      mysqli_stmt_execute($proc);
      $mysql_error = mysqli_error($link);
      if ($mysql_error!="") {
          printf("Unexpected database error: %s\n", $mysql_error);
          mysqli_stmt_close($proc);
          mysqli_clean_connection($link);
          exit();
      } else
      {
          mysqli_stmt_close($proc);
          mysqli_clean_connection($link);
          update_completion_status($respondent_id, 'Started');
          header("Location: index.php?r=".$rguid);
      }
  </code></pre>
  
  <p>Where am I going wrong?</p>