title: On click file download, on success redirect to another page using AJAX
body: <p>In my WordPress project, my <kbd><strong>Download</strong></kbd> button containing a <code>.zip</code> file, which onClick should be downloaded. So the HTML producing is:</p>
  
  <pre><code>&lt;a id="732" class="btn btn-default download-link" href="https://example.com/download.zip"&gt;DOWNLOAD&lt;/a&gt;
  </code></pre>
  
  <p>I'm using AJAX to refresh the download count.</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  var ajaxurl = '&lt;?php echo admin_url('admin-ajax.php'); ?&gt;';
  jQuery(document).on('click', '.download-link', function () {
      var id = this.id;
  
      jQuery.ajax({
          type: 'POST',
          url: ajaxurl,
          data: {"action": "count_download",
                      "id": id
                  },
          success: function (data) {
              window.location = site.url + "/download-success?fid="+ id;
          }
      });
  });
  &lt;/script&gt;
  </code></pre>
  
  <p>Everything works fine until I added the file with the link. Typically such a link will start downloading the <code>.zip</code> file, but even after the time taken by the AJAX call the page redirected to the download-success page without triggering the download.</p>
  
  <p>And it occurs most of the time, only once or twice the file starts downloading.</p>
  
  <p><strong>P.S.:</strong> I tested <a href="https://stackoverflow.com/a/4373955/1743124">this</a> but it's not my case.</p>