Thanks for your reply Gareth, however what I am trying to achieve is a
little different.
I have a page (complicated with multiple panels/ Tabs - but very
simple for the user) that the user completes and then clicks on a
button. If the server app rejects the transaction then I want the
error message to appear within a div. If the server accepts the
transaction then I want the server to create a pdf document which then
opens in a separate window for the user, whilst the original window
prepares itself for the next transaction.
At the moment the error is returned to the div correctly, but when I
try to send the user the pdf (including http headers and mime type)
instead of this opening in a new page it displays as hyroglyphics in
my div. What I need was some way to tell prototype to stop listening
for a response and allow all further data to be received by the
browser.
I have since tried to split this into two processes but am now having
problems the program flow i.e.
Process 1 validates and saves the data, then initiates process2
Process 2 Creates PDF, Clears the data back to default values,
Displays the PDF
Because Process 1 finishes before Process 2 starts, the data has not
yet been set back to default values and the users screen (on printing
and closing the PDF) does not contain the default values. Because
Process 2 needs the data from the transaction Process 1 cannot be used
to default it.
On Mar 13, 7:50 pm, "Gareth Evans"
<agr...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> You can''t typically instantiate a file download of an embedded
object in a
> div.
> I may be wrong but i''ve never seen it done.
> Usually, if you want to start a download, you use http headers and an
> iframe. You can set it to download or embed.
> If you want to download, you can set the width/height of the iframe to 0.
>
> I would build what you want in 2 requests- one to validate the data and
save
> it, and the other to generate the pdf from the saved data.
> Call the first request
> Get the result
> If the result is "ERROR" then stick it in the div
> If the result is "OK" then get the resulting url, if it has to be
generated
> from the data and add a new iframe to your document to instantiate the
> download.
>
> Here is some cross browser add-iframe code.
> It is not prototype.
>
> function addIframe (url) {
> if (document.all)
> document.body.insertAdjacentHTML(''beforeEnd'',
> ''<IFRAME WIDTH="0" HEIGHT="0"
SRC="'' + url + ''"><\/IFRAME>'');
> else if (document.getElementById) {
> var ifr = document.createElement(''IFRAME'');
> ifr.src = url;
> ifr.width = 0;
> ifr.height = 0;
> document.body.appendChild(ifr);
> }
>
> }
>
> On 3/14/07, oldandgrey
<oldandg...-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org> wrote:
>
>
>
> > I''m trying to use the ajax.Updater function to send a message
to the
> > server and display an error message. Ok so far. However if the server
> > detects no error with the data sent I want to open a PDF file in a new
> > window. When I try to do this (using fpdf) the returned PDF is opened
> > as text in the error div.
>
> > Can anyone point me in the right direction.
>
> > rgds
>
> > gmcb
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---