title: ajax is working without event.preventDefault(); - but breaks if added event.preventDefault();
body: <p>I've built an AJAX request to insert a new row to mySql and to get back the updated database as an array. It works perfectly without <code>event.preventDefault();</code> (and redirects to the PHP file) - but it breaks when I added <code>event.preventDefault();</code> to prevent redirect.</p>
  
  <p>Any ideas?</p>
  
  <pre><code>$("#upload-form").submit(function() {
      //event.preventDefault();
      window.alert(paintsCatlg.length);
  
      document.querySelector("#upload-form #id").value = paintsCatlg.length;
      document.querySelector("#upload-form #src").value = "paintings//" + document.querySelector("#upload-form #exhibition_en").value + "//" + fileName;
      window.alert(document.querySelector("#upload-form #id").value);
      window.alert(document.querySelector("#upload-form #src").value);
  
      var uploadForm = new FormData();
      uploadForm.append("id", $('#id').val());
      uploadForm.append("src", $('#src').val());
      uploadForm.append("title_en", $('#title_en').val());
      uploadForm.append("title_he", $('#title_he').val());
      uploadForm.append("exhibition_en", $('#exhibition_en').val());
      uploadForm.append("exhibition_he", $('#exhibition_he').val());
      uploadForm.append("subjects_en", $('#subjects_en').val());
      uploadForm.append("subjects_he", $('#subjects_he').val());
      uploadForm.append("keywords_en", $('#keywords_en').val());
      uploadForm.append("keywords_he", $('#keywords_he').val());
      uploadForm.append("height", $('#height').val());
      uploadForm.append("width", $('#width').val());
      uploadForm.append("sold", $('#sold').val());
      var settings = {
          // "async": true,
          // "crossDomain": true,
          "url": "upload.php",
          "method": "POST",
          "dataType": 'json',
          "processData": false,
          "contentType": false,
          "mimeType": "multipart/form-data",
          "data": uploadForm
      }
  
      $.ajax(settings).success(function(data) {
          //   alert("Hello! I am an alert box!!");
          alert('good');
          alert(data);
          paintsCatlg = data;
      });
  });
  </code></pre>
  
  <pre class="lang-php prettyprint-override"><code>$servername = "localhost";
  $username = "root";
  $password = "";
  $dbname = "chana_goldberg";
  
  // Create connection
  $conn = new mysqli($servername, $username, $password, $dbname);
  $conn-&gt;set_charset("utf8");
  
  // Check connection
  if ($conn-&gt;connect_error) {
      die("Connection failed: " . $conn-&gt;connect_error);
  } 
  
  // if(isset($_POST['submit'])) {
  //   unset($_POST['submit']);
  $id = $_POST['id'];    
  $src = $_POST['src'];
  $title_en = $_POST['title_en'];
  $title_he = $_POST['title_he'];
  $exhibition_en = $_POST['exhibition_en'];
  $exhibition_he = $_POST['exhibition_he'];
  $subjects_en = $_POST['subjects_en'];
  $subjects_he = $_POST['subjects_he'];
  $keywords_en = $_POST['keywords_en'];
  $keywords_he = $_POST['keywords_he'];
  $height = $_POST['height'];
  $width = $_POST['width'];
  $sold = $_POST['sold'];
  $enc_exhibition = mb_convert_encoding($exhibition_en, "ASCII");
  $target_dir = "paintings/$enc_exhibition/";
  // $src = "paintings/$enc_exhibition/";
  if ( ! is_dir($target_dir)) {
      mkdir($target_dir);
  }
  
  $target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
  $uploadOk = 1;
  $imageFileType = pathinfo($target_file,PATHINFO_EXTENSION);
  // Check if image file is a actual image or fake image
  if(isset($_POST["submit"])) {
      $check = getimagesize($_FILES["fileToUpload"]["tmp_name"]);
      if($check !== false) {
          // echo "File is an image - " . $check["mime"] . ".";
          $uploadOk = 1;
      } else {
          echo "File is not an image.";
          $uploadOk = 0;
      }
  }
  // Check if file already exists
  if (file_exists($target_file)) {
      echo "Sorry, file already exists.";
      $uploadOk = 0;
  }
  // Check file size
  if ($_FILES["fileToUpload"]["size"] &gt; 500000) {
      echo "Sorry, your file is too large.";
      $uploadOk = 0;
  }
  // Allow certain file formats
  if($imageFileType != "jpg" &amp;&amp; $imageFileType != "png" &amp;&amp; $imageFileType != "jpeg"
     &amp;&amp; $imageFileType != "gif" ) {
      echo "Sorry, only JPG, JPEG, PNG &amp; GIF files are allowed.";
      $uploadOk = 0;
  }
  // Check if $uploadOk is set to 0 by an error
  if ($uploadOk == 0) {
      echo "Sorry, your file was not uploaded.";
      // if everything is ok, try to upload file
  } else {
      if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
          $exhibition_en = mysql_real_escape_string($exhibition_en);
  
          $stmt = $conn-&gt;prepare("INSERT INTO paintings_catalog (src, title_en, title_he, exhibition_en, exhibition_he, subjects_en, subjects_he, keywords_en, keywords_he, height, width, sold) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
          $stmt-&gt;bind_param("ssssssssiiss", $src, $title_en, $title_he, $exhibition_en, $exhibition_he, $subjects_en, $subjects_he, $keywords_en, $keywords_he, $height, $width, $sold);
  
          $stmt-&gt;execute();
  
          $query = "SELECT * FROM paintings_catalog ORDER BY id";
          $result = $conn-&gt;query($query);
  
          // numeric array
          $paintsCatlg[] = array(1 =&gt;'');
          while ($row = $result-&gt;fetch_array(MYSQLI_NUM)){
              $paintsCatlg[] = $row;
  
  
          };
  
          echo json_encode($paintsCatlg);
      }
  }
  </code></pre>