I'm using ajax to POST, but AJAX won't trigger the file download.
I need to POST without using forms, because I'm using values from many elements on page, so I made a javascript function to get those values and create an array then POST to the php target file.
How can I POST these values and trigger the download the file, without using form submit, but collecting the elements values and sending it to the target php page?
Javascript parses content and creates an array of values, and post to PHP:
['Jordan','22','Male','Other Info']
PHP file uses that array to insert these values into a DOCX (document), then returns the download URL, note that the file isn't kept in the server.
Here's the ajax POST answer:
Access-Control-Allow-Origin:*
Cache-Control:max-age=0, no-cache, no-store, must-revalidate
Connection:Keep-Alive
Content-Description:File Transfer
Content-Disposition:attachment; filename="modelos/calculos/tempo_contribuicao_2014-11-12.docx"
Content-Length:18943
Content-Transfer-Encoding:binary
Content-Type:application/vnd.openxmlformats-officedocument.wordprocessingml.document
Date:Wed, 12 Nov 2014 15:57:39 GMT
Expires:Wed, 11 Jan 1984 05:00:00 GMT
Keep-Alive:timeout=15, max=98
Pragma:no-cache
Server:Apache/2.0.63 (FreeBSD) PHP/5.2.6 with Suhosin-Patch
Vary:User-Agent
X-Powered-By:PHP/5.2.6