title: Using jQuery AJAX to download a binary file
body: <p>I am attempting to use jQuery AJAX to download a binary audio file.  </p>
  
  <p>Normally I would just issue a command like this:</p>
  
  <pre><code> windows.location.href = 'http://marksdomain(dot)com/audioFile.wav' ;
  </code></pre>
  
  <p>However, recently our server has been waiting too long to respond, and I get a nasty gateway timeout message.</p>
  
  <p>It has been suggested that I use jQuery AJAX instead, which makes sense since then i would have more control over the timeout.</p>
  
  <p>Here is the code i have played with so far:</p>
  
  <pre><code>$.ajax({
      url: 'http://marksdomain(dot)com/audioFile.wav',
      timeout: 999999,
      dataType: 'binary',
      processData: false, // this one does not seem to do anything ?
  
      success: function (result) {
          console.log(result.length);
      },
      error: function (result, errStatus, errorMessage) {
          console.log(errStatus + ' -- ' + errorMessage);
      }
  };
  </code></pre>
  
  <p>When I omit the "dataType", the binary file is coming through about three times larger than it actually is on the server.  However, when i make the dataType equal to "binary", AJAX throws an error:</p>
  
  <pre><code>"No conversion from text to binary"
  </code></pre>
  
  <p>From some earlier posts, it sounds as if jQuery AJAX cannot handle binary files in this manner.</p>
  
  <p>I did discover <a href="https://www.npmjs.com/package/delivery" rel="noreferrer">Delivery.js</a> which actually works quite well for what I am attempting, but I would rather not use a node solution if possible.</p>
  
  <p>Any suggestions?</p>