title: How do I offer an Ajax POST response to the user as a download?
body: <p>I'm trying to include a vCard export function in an existing page full of account information.</p>
  
  <p>The ugly methods would involve 1, submitting a form to the same page, processing it and re-rendering the whole page, or 2, a GET targeting an iframe on the page.  I'd really like to avoid both of those, but I may have to use #2 to achieve the goal.</p>
  
  <p>Right now I have:</p>
  
  <pre><code>&lt;input type="image" src="/intra/imgs/icons/vcard.png" onclick="$.post('/intra/vcard.php', { id: '992772', type: 'sponsor'});"&gt;
  </code></pre>
  
  <p>Which works in the sense that if I watch XHR activity in Firebug I see the request come back with the correct response, full of vCard formatted data.  However it does not prompt the user to download the response as a file, even though the card is sent with:</p>
  
  <pre><code>header('Content-Type: text/x-vcard');
  header("Content-Disposition: attachment; filename={$this-&gt;name_first}{$this-&gt;name_last}.vcf");
  </code></pre>
  
  <p>Am I doing something wrong, or is this just not possible?</p>