By: usrAnonymous
Date: 2014-11-12
Time: 17:42
|
AJAX post, then download file
Is there a way to achieve that?
I cannot use submission, I'm currently using javascript to parse elements values, which are many and are all around the page.
How can I download the file after the POST?
The POST is returning the attachment but Javascript will not download it, here's the 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 16:35:31 GMT
Expires:Wed, 11 Jan 1984 05:00:00 GMT
Keep-Alive:timeout=15, max=97
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
|
|
By: Skrol29
Date: 2014-11-12
Time: 23:46
|
Re: AJAX post, then download file
Hi,
This is not a problem concerning TBS or OpenTBS.
An Ajax post cannot perform an HTML download.
You have to use Javascript but without an Ajax call. You have to use Javascript for a POST or a GET request. Since the header's reply has attachment information, the request will be processed by the navigator as a download.
|
By: usrAnonymous
Date: 2014-11-13
Time: 12:52
|
Re: AJAX post, then download file
Thanks for your help!
If I use javascript POST or GET it will work?
Could you link me somewhere or paste a code example of javascript POST or GET?
Thank you very much! I'm loving OpenTBS!
|
By: Skrol29
Date: 2014-11-13
Time: 12:59
|
Re: AJAX post, then download file
With Javascript a GET is performed simply by calling a news URL having the parameters in the URL:
document.location.href = ...
A POST is performed by submitting a form.
my_form.submit()
|
By: usrAnonymous
Date: 2014-11-13
Time: 13:20
|
Re: AJAX post, then download file
Ah, the problem is that the GET wouldn't work, because I'm working with huge ammount of data, most browsers have limit to the url size.
Form wouldn't help me I guess, because I'm parsing info from tables, divs, everywhere in the page.
Do you know a solution for my problem?
Thanks.
|
By: Skrol29
Date: 2014-11-13
Time: 14:17
|
Re: AJAX post, then download file
|
By: usrAnonymous
Date: 2014-11-13
Time: 14:26
|
Re: AJAX post, then download file
Thank you for your help :)
|
By: Anonymous
Date: 2014-11-13
Time: 16:19
|
Re: AJAX post, then download file
Worked handsomely ;)
|
|
Posting in progress.
Please wait...
|