On 7/14/05, Shelby Westman
<shelby.westman-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> I''m new to Rails and Ajax. I have a question about how Ajax
actually
> works. If I understand correctly, an Ajax action just returns an html
> fragment. So, for example, let''s say I have a form that is
updating
> an object. I might want to use Ajax to add to a list, as shown in
> some of the tutorials. Bul all Ajax does is add html to the list, it
> does not update the object and send the updated object back to the
> browser, right?
>
> I guess you could send it along the object ID and have the controller
> action look up the object and update the field in question. However,
> the actual updated object is not sent back to the view page for
> redisplay, rather only an html fragment can be sent back.
>
> Am I right in my understanding?
This is a very implementation specific question, but I would venture
to say that the general behavior of most uses of Ajax does update the
object on the backend (i.e. in the database).
Take a blog as an example. I create a blog supports leaving comments
via an Ajax-powered form. This way when a user leaves a new comment
the page doesn''t have to be fully refreshed. The Rails
component/action that handled this Ajax request would take the conents
of the form a write them to the database and then render the partial
that represents the comment on my website. In this case there is
definitely an object being altered (created, really) that represents
the comment.
In other cases, it may not be necessary, but I''m not coming up with a
good example at this time.
Does that help?
Cheers,
bs.
--
http://blog.benschumacher.com/