# Ajax to download a file

**URL:** <https://www.ruby-forum.com/t/ajax-to-download-a-file/191921>\
**Category:** Rails\
**Created:** [July 20, 2010, 6:49pm UTC](https://www.ruby-forum.com/t/ajax-to-download-a-file/191921 "2010-07-20T18:49:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![flamingsole](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/f19dbf/32.png) [@flamingsole](https://www.ruby-forum.com/u/flamingsole)\
**Post date:** [July 20, 2010, 6:49pm UTC](https://www.ruby-forum.com/t/ajax-to-download-a-file/191921/1 "2010-07-20T18:49:26Z")

</div>

Hi

I would like to download a file in an asynchronous manner. From what I  
have read, I should be using a hidden iframe. How do I connect the AJAX  
request to the iframe to display the file?

Thanks

---

<div class="post-metadata">

**Author:** ![flamingsole](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/f19dbf/32.png) [@flamingsole](https://www.ruby-forum.com/u/flamingsole)\
**Post date:** [July 20, 2010, 7:31pm UTC](https://www.ruby-forum.com/t/ajax-to-download-a-file/191921/2 "2010-07-20T19:31:12Z")

</div>

Jonathan S. wrote:

> Hi
> 
> I would like to download a file in an asynchronous manner. From what I  
> have read, I should be using a hidden iframe. How do I connect the AJAX  
> request to the iframe to display the file?
> 
> Thanks

This is probably better asked on a JavaScript forum. It certainly has  
nothing to do with Rails.

## Best,

Marnen Laibow-Koser  
[http://www.marnen.org](http://www.marnen.org)  
removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![flamingsole](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/f19dbf/32.png) [@flamingsole](https://www.ruby-forum.com/u/flamingsole)\
**Post date:** [July 20, 2010, 7:32pm UTC](https://www.ruby-forum.com/t/ajax-to-download-a-file/191921/3 "2010-07-20T19:32:54Z")

</div>

You’re mostly correct, but yes, I will post it somewhere on a javascript  
board.

Marnen Laibow-Koser wrote:

> Jonathan S. wrote:
> 
> > Hi
> > 
> > I would like to download a file in an asynchronous manner. From what I  
> > have read, I should be using a hidden iframe. How do I connect the AJAX  
> > request to the iframe to display the file?
> > 
> > Thanks
> 
> This is probably better asked on a JavaScript forum. It certainly has  
> nothing to do with Rails.
> 
> ## Best,
> 
> Marnen Laibow-Koser  
> [http://www.marnen.org](http://www.marnen.org)  
> removed\_email\_address@domain.invalid
