title: How to implement file download functionality using Node.js and express, so that the user is prompted to save the file?
body: <p>Basically I would like to have a button that people could click to export some data.  Currently I have this hooked up to an ajax call that hits some code I have on the server to get the data.  Unfortunately the user is never prompted to save a file or anything, the call is just successfully made.  </p>
  
  <p>If I look at the response to the ajax call it has the JSON that I want to export in it.  Here is the code I have come up with so far:</p>
  
  <pre><code>#exportData is just a function that gets data based off of a surveyId
  @exportData req.body.surveyId, (data) -&gt;
      res.attachment('export.json')
      res.end(JSON.stringify(data),'UTF-8')
  </code></pre>
  
  <p>Any suggestions to get this to prompt the user to save the file rather than just quietly returning the data?</p>