title: Download a file and reload a page once the file is downloaded
body: <p>I am trying to download a file and then reload the page. </p>
  
  <p>The issue is that this code works only when the file download is completed within a second.<br>
  If the file is any bigger the first request to download the file seems to be blocked by the second request.</p>
  
  <p><em>javascript:</em></p>
  
  <pre class="lang-js prettyprint-override"><code>//downloads the file
  function updateAndDownload() {
  
    var link = document.createElement('a');
    link.href = "updateAndDownloadFile.rails?id=$ID";
    document.body.appendChild(link);
    link.click();
    PageReload();
  }
  //wait for a second and refresh the page
  function PageReload() {
    setTimeout(function() {
      refreshPage();
    }, 1000);
  }
  
  function refreshPage() {
    // Close dialog.
    Control.Modal.close();
  
    // Reload.
    window.location.href = "index.rails?id=" + ID
  }
  </code></pre>
  
  
  
  <p>I expect the file to be downloaded and the page to be refreshed maybe back to back or at the same time</p>