aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes Displaying Binary Data Fetched with AJAX 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 "Displaying Binary Data Fetched with AJAX" Watch "Displaying Binary Data Fetched with AJAX" New topic
Author

Displaying Binary Data Fetched with AJAX

David Bates
Ranch Hand

Joined: Sep 03, 2006
Posts: 32
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?


<a href="http://www.trycatch.net" target="_blank" rel="nofollow">http://www.trycatch.net</a>
Susanta Chatterjee
Ranch Hand

Joined: Aug 12, 2002
Posts: 102
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

Joined: Sep 03, 2006
Posts: 32
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

Joined: May 24, 2003
Posts: 425
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

Joined: Nov 08, 2001
Posts: 15376
    
    6
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

Joined: Sep 03, 2006
Posts: 32
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

Joined: Nov 08, 2001
Posts: 15376
    
    6
http://forum.java.sun.com/thread.jspa?threadID=548763&messageID=4368470

Eric
David Bates
Ranch Hand

Joined: Sep 03, 2006
Posts: 32
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

Joined: Nov 08, 2001
Posts: 15376
    
    6
It showed you how to post the form to another window. Isn't that what you were asking?

Eric
David Bates
Ranch Hand

Joined: Sep 03, 2006
Posts: 32
Sure, but I can't see it suggesting a technique that hasn't been discussed above, that's all.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Displaying Binary Data Fetched with AJAX