title: Safari 11.1: ajax/XHR form submission fails when input[type=file] is empty
body: <p><strong>UPDATE</strong>: As of <a href="https://trac.webkit.org/changeset/230963/webkit" rel="noreferrer">Webkit build r230963</a>, this issue has been resolved in Webkit.</p>
  
  <p>===========</p>
  
  <p>Since the recent Safari 11.1 update on macOS and iOS, as well as in Safari Technology Preview 11.2, the <code>$.ajax</code> calls in my web application are failing when a <code>input[type=file]</code> field has no file chosen (it isn't required in my form). No failure when the field <em>does</em> have a file chosen.</p>
  
  <p>The <code>error</code> callback of <code>ajax</code> runs and the Safari console contains the following message: <code>Failed to load resource: The operation couldn’t be completed. Protocol error</code>. I am HTTPS and submitting to a location on the same domain (and server) also over HTTPS.</p>
  
  <p>Before the 11.1 update, the <code>$.ajax</code> call submitted just fine when no file was chosen. The latest versions of Chrome and Firefox have no issues.</p>
  
  <p>Relevant parts of my code:</p>
  
  <p>The input:</p>
  
  <pre><code>Browse... &lt;input id="file-upload" type="file" name="image" accept=".jpg,.jpeg"&gt;
  </code></pre>
  
  <p>The JS:</p>
  
  <pre><code>var formData = new FormData($(this)[0]);
  $.ajax({
      type: 'POST',
      enctype: 'multipart/form-data',
      url: '../process.php',
      data: formData,
      contentType: false,
      processData: false,
      cache: false,
      success: function(response) { ... },
      error: function() { //my code reaches here }
  });
  </code></pre>
  
  <p>As a temporary (hopefully) solution, I'm detecting an empty file field and removing it from <code>formData</code> before the <code>ajax</code> call and everything works as expected/before:</p>
  
  <pre><code>$("input[type=file]").each(function() {
      if($(this).val() === "") {
          formData.delete($(this).attr("name"));
      }
  });
  </code></pre>
  
  <p>Am I doing something wrong, is there an issue with Safari, or is there a change in Safari that needs to be accounted for now in ajax calls?</p>