This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Displaying Binary Data Fetched with AJAX

 
David Bates
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm using an AJAX (POST) call to a servlet which streams back a Microsoft Word document. I arrives back safely, but I don't know how to spawn a new window (window.open) and populate it with the contents of that Word document. Any thoughts?
 
Susanta Chatterjee
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi David,
What about opening a new window first and using javascript in the new window to do a form submit to get the server side to stream your application data?

My 2 cents.

- Susanta
 
David Bates
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks. I had thought of that and it's what I'll do if all else fails.

I just think there has to be a way of passing back the binary data to the window.
 
Purushoth Thambu
Ranch Hand
Posts: 425
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From the parent window you can open a new window and obtain the reference to document of the new window


This should work
[ September 26, 2006: Message edited by: Purushothaman Thambu ]
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should just call the serverside page directly in the window.open or an in iframe. Do not do an Ajax call since JavaScript can not handle binary data.

Eric
 
David Bates
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should just call the serverside page directly in the window.open or an in iframe. Do not do an Ajax call since JavaScript can not handle binary data.


Agreed, doing some more digging it does appear AJAX just isn't fitted for fetching binary data.

However, how can you specify a POST method using the techniques you suggest?
 
Eric Pascarello
author
Rancher
Posts: 15385
6
 
David Bates
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Eric, was there something different I was meant to see in that link? It looks like the "hidden form submitted using Javascript" technique discussed earlier:

 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It showed you how to post the form to another window. Isn't that what you were asking?

Eric
 
David Bates
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sure, but I can't see it suggesting a technique that hasn't been discussed above, that's all.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic