title: Ajax Success and Error function failure
body: <p>I am having trouble getting my jQuery ajax to work properly. It directs to the PHP page to update the database, but never returns back to the script for the success or error options.</p>
  
  <p>My code is below:</p>
  
  <pre><code>$(document).ready(function(){  
          $("form#updatejob").submit(function() {  
              function textreplace(x) {return text.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&amp;");}
              // we want to store the values from the form input box, then send via ajax below
              var job     = $("#job").attr("value");
              var description     = $("#description").val();
              description.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&amp;");
              var startDate   = $("#startDate").attr("value");
              var releaseDate = $("#releaseDate").attr("value");  
              var status  = $("#status").attr("value"); 
              $.ajax({
                  beforeSend:textreplace(description),
                  type: "POST",  
                  url: "updatedjob.php",
                  data: "jobID="+ job +"&amp; description="+ description +"&amp; startDate="+ startDate +"&amp; releaseDate="+ releaseDate +"&amp; status="+ status, 
                  success: function(){  
                      $("form#updatejob").hide(function(){$("div.success").fadeIn();});  
                  },
                  error: function(XMLHttpRequest, textStatus, errorThrown) { 
                      alert("Status: " + textStatus); alert("Error: " + errorThrown); 
                  }       
              });
              return false;  
          });  
  });
  </code></pre>
  
  <p>And the PHP:</p>
  
  <pre><code>&lt;?php 
      include("connect.php"); 
      $job = trim($_POST['job']); 
      $startDate = trim($_POST['startDate']); 
      $releaseDate = trim($_POST['releaseDate']); 
      $mysqlstartdate = date('Y-m-d', strtotime($startDate)); 
      $mysqlreleasedate = date('Y-m-d', strtotime($releaseDate)); 
      $description = trim($_POST['description']); 
      $status = trim($_POST['status']); 
      $update = "UPDATE jobs SET startDate = '$mysqlstartdate', releaseDate = '$mysqlreleasedate', description = '$description', status = '$status' WHERE jobID = '$job' "; 
      $rsUpdate = mysql_query($update);
  // or die(mysql_error()); mysql_close(); 
  ?&gt;
  </code></pre>