# Trouble with AJAX-like uploads

**URL:** <https://www.ruby-forum.com/t/trouble-with-ajax-like-uploads/123076>\
**Category:** Rails\
**Created:** [December 13, 2007, 9:17pm UTC](https://www.ruby-forum.com/t/trouble-with-ajax-like-uploads/123076 "2007-12-13T21:17:44Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dracos](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ea666f/32.png) [@dracos](https://www.ruby-forum.com/u/dracos)\
**Post date:** [December 13, 2007, 9:17pm UTC](https://www.ruby-forum.com/t/trouble-with-ajax-like-uploads/123076/1 "2007-12-13T21:17:44Z")

</div>

So I’ve been following various tutorials to implement an ajax-like file  
upload using responds\_to\_parent and iframe targets, but can’t quite  
close the deal. My file uploads successfully, but the rjs doesn’t work  
(my ‘events’ partial, which refreshes fine with this controller code  
when called with form\_remote\_tag, doesn’t refresh).

Can anyone who’s done this before see what’s missing?

Thanks,

Peter

View:

\<% form\_tag({:action=\>‘upload’}, :multipart =\> true, :target =\> “frame”)  
do %\>  
\<%= file\_field\_tag “uploaded\_file” %\>  
\<%= submit\_tag ‘Upload’ %\>  
\<% end %\>

Controller:

def upload  
event = Event.new  
event.date = Date.today  
if event.save  
File.open("#{RAILS\_ROOT}/uploaded.rtf", “wb”) do |f|  
f.write(params[‘uploaded\_file’].read)  
end  
responds\_to\_parent do  
render :update do |page|  
page.replace\_html “event\_list”, :partial =\> “events”  
end  
end  
end  
end

---

<div class="post-metadata">

**Author:** ![dracos](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ea666f/32.png) [@dracos](https://www.ruby-forum.com/u/dracos)\
**Post date:** [December 17, 2007, 11:50pm UTC](https://www.ruby-forum.com/t/trouble-with-ajax-like-uploads/123076/2 "2007-12-17T23:50:36Z")

</div>

I should also mention that I get the following RJS error upon  
submission:

TypeError: Value undefined (result of expression Element.update) is not  
object.
