• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

AJAX responseText as pdf

 
Zip Ped
Ranch Hand
Posts: 336
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You just plain can't do that with Ajax.
 
Zip Ped
Ranch Hand
Posts: 336
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Cool. Thats all i needed to know.

Thanks Gregg.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65229
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Garrett Smith
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Because then it isn't 'AJAX'?
 
Zip Ped
Ranch Hand
Posts: 336
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 504
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65229
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As has already been stated, Ajax is not a suitable technology for this.
 
Neha Daga
Ranch Hand
Posts: 504
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 65229
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just use a regular submission. Triggering the Save As dialog on the browser depends upon the browser receiving the response.
 
Neha Daga
Ranch Hand
Posts: 504
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
it worked

Thanks you very much Bear
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic