Forum: Ruby on Rails send_file using AJAX

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
C95664a5c59ccdfb0da2f5910675c62c?d=identicon&s=25 Sudhi Kulkarni (sudhi)
on 2009-03-26 07:25
I have a AJAX based form and when I use send_file there is no pop-up
that appears to prompt user to download file... how do I fix this?

Regards,
Sudhindra
36ed63ef68c172f148c491418395d0b5?d=identicon&s=25 rubyguy@ymail.com (Guest)
on 2009-03-26 08:50
(Received via mailing list)
On 26 Mar., 07:25, Sudhi Kulkarni <rails-mailing-l...@andreas-s.net>
wrote:
> I have a AJAX based form and when I use send_file there is no pop-up
> that appears to prompt user to download file... how do I fix this?

http://www.catb.org/~esr/faqs/smart-questions.html#beprecise

--
Best regards,
David Knorr
http://twitter.com/rubyguy
Aafa8848c4b764f080b1b31a51eab73d?d=identicon&s=25 Phlip (Guest)
on 2009-03-26 12:54
(Received via mailing list)
Sudhi Kulkarni wrote:

> I have a AJAX based form and when I use send_file there is no pop-up
> that appears to prompt user to download file... how do I fix this?

Did you Google for that first? It's a FAQ in Ajax-land, because browsers
have
security constraints that prevent JavaScript from manipulating file
input elements.

The answer is do old-fashioned Ajax that bypasses JavaScript. When a
form's
target field is the name of a 1-pixel <iframe> (and when it's not a
remote_form_* and hence calls no JS), submitting the form will send its
data
into that <iframe>, and into your server without refreshing your page.

Google for that FAQ to learn how to update your page after the call,
because I
forget.

--
   Phlip
   http://www.zeroplayer.com/
This topic is locked and can not be replied to.