I am trying to enable the vCard export feature on an existing account information page.
Ugly methods include 1, submitting the form to the same page, processing it and re-rendering the entire page, or 2, GET, targeting the iframe on the page. I would really like to avoid both, but I may have to use No. 2 to achieve the goal.
Now I have:
<input type="image" src="/intra/imgs/icons/vcard.png" onclick="$.post('/intra/vcard.php', { id: '992772', type: 'sponsor'});">
Which works in the sense that if I observe XHR activity in Firebug, I see that the request returns with the correct answer, full of data in vCard format. However, it does not ask the user to download the response as a file, even if the card is sent using:
header('Content-Type: text/x-vcard');
header("Content-Disposition: attachment; filename={$this->name_first}{$this->name_last}.vcf");
Am I doing something wrong, or is it just not possible?