Forum: Ruby on Rails Update specific div using post request.

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.
3548d30217e9921c410db19ce8ce38d0?d=identicon&s=25 Sunny Bogawat (sunny_bogawat)
on 2009-01-07 16:53
It is possible to update specific div in my rhtml file using post
request like ajax do?
989aa38adf6609c302f172655bb940d9?d=identicon&s=25 Nirav Parekh (Guest)
on 2009-01-09 10:33
(Received via mailing list)
It is possible to update a specific div using a post request like AJAX
do.
you need to use link_to_remote method for this.

What does this link_to_remote method does...

Returns a link to a remote action defined by options[:url] (using the
url_for format) that's called in the background using XMLHttpRequest.
The
result of that request can then be inserted into a DOM object whose id
can
be specified with options[:update]. Usually, the result would be a
partial
prepared by the controller with render :partial.
(from apis)
eg.

link_to_remote ("Delete", :update=>"posts", :url=> {:action =>"destroy",
:id=>post.id})

the above function call will generate a link called Delete which when
called
will delete the item specified by the id and simultaneously update the
div
having the id "posts" without reloading the page.

link_to_remote requests are posts so don't need to worry about it.
This topic is locked and can not be replied to.