aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes AJAX responseText as pdf Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "AJAX responseText as pdf" Watch "AJAX responseText as pdf" New topic
Author

AJAX responseText as pdf

Zip Ped
Ranch Hand

Joined: Jul 26, 2005
Posts: 336
Hi,

I am trying to display a PDF file by retrieving the response(pdf)from my server through AJAX.

Once, i retrieve the response from the server in the xmlHttpRequest.responseText field, I am writing the responseText to my page:



However this does not work for me as the PDF isnt displayed. What am I missing or what am I doing wrong here?
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

You just plain can't do that with Ajax.


GenRocket - Experts at Building Test Data
Zip Ped
Ranch Hand

Joined: Jul 26, 2005
Posts: 336
Cool. Thats all i needed to know.

Thanks Gregg.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61237
    
  66

If you are going to replace the page with whatever comes back from an Ajax call, PDF or otherwise, what's the point of using Ajax rather than just going to the page?
[ May 16, 2007: Message edited by: Bear Bibeault ]

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Garrett Smith
Ranch Hand

Joined: Jun 27, 2002
Posts: 401
Because then it isn't 'AJAX'?


comp.lang.javascript FAQ: http://jibbering.com/faq/
Zip Ped
Ranch Hand

Joined: Jul 26, 2005
Posts: 336
The point is I needed to know if my child window displays a PDF field successfully. I wasnt able to figure out a way to determine if my response in the child window contained a PDF. Based on that, I needed to execute javascript in the parent window after opening the child window.

The reason I used AJAX was to wait till the response came back from the server and then I could execute the parent windows javascript.

Makes sense?
Neha Daga
Ranch Hand

Joined: Oct 30, 2009
Posts: 504
Hi All,

My program is a simple one which takes a string and converts it to a barcode and then returns pdf file with that barcode as response.
I want to open a save as box on the browser for the user to save this barcode pdf file.

This is what I am doing:

I am using ajax for this.
but the response does not open a save as dialogue instead it shws whatever was returned as text.

Please help.


SCJP 1.6 96%
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61237
    
  66

As has already been stated, Ajax is not a suitable technology for this.
Neha Daga
Ranch Hand

Joined: Oct 30, 2009
Posts: 504
Thank you Bear.
I am all new to this thing and can't figure out how to do this.
Can you please help me on alternatives?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61237
    
  66

Just use a regular submission. Triggering the Save As dialog on the browser depends upon the browser receiving the response.
Neha Daga
Ranch Hand

Joined: Oct 30, 2009
Posts: 504
it worked

Thanks you very much Bear
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: AJAX responseText as pdf