title: Get script to wait for file dialogue to return
body: <p>I have a web page where I want to prompt the user for a file to upload, but I don't want to display the <code>&lt;input type="file"/&gt;</code> element.</p>
  
  <p>I have a button that triggers the file dialogue to display, but the code doesn't wait for the dialogue to return.</p>
  
  <p>Is there an event I can hook into that is raised when the file dialogue returns? Is there some other thing I've not thought of?</p>
  
  <p>This is what I have at the moment, it uses an alert to block the code. I want something less hacky.</p>
  
  <pre><code>function importValues(e)
  {
      var f = document.getElementById('file');
      f.click();
      alert('loading'); //hack to make the code wait for the user to choose a file before making the ajax call
      var formdata = new FormData(jQuery('#frmImport')[0]);
      jQuery.ajax({
          url: 'importFile',
          type: 'POST',
          data: formdata,
          chache: false,
          contentType: false,
          processData: false,
      });
  }
  </code></pre>