Women in Technology

Hear us Roar



Article:
  Ajax on Rails
Subject:   still confused
Date:   2005-09-19 11:33:10
From:   rhubarbo
I don't claim to know anything about rails, ruby or even AJAX, but I'm learning all three simultaneously and I'd really like to get this clear in my head.


The first page of this article describes AJAX in RoR Thus:


How Rails Implements Ajax


(simplifying)


1. trigger action - e.g. user making changes to the data on a form


2. Form Data sent asynchronously action handler on the server via XMLHttpRequest.


3. The server-side action handler ... returns an HTML fragment as its response.


4. The client-side JavaScript updates a specified part of the current page's HTML



Now I can see how this is much more responsive than a typical web app where the whole page is submitted then reloaded. In fact I see the Ajaxy elements as:


a) the form data is sent asynchronously and perhaps could be sent as the user types instead of after submit
b) a section of the page is updated instead of the whole page


But in general - it looks like you describe a normal web-app-like interaction - that is a full server round-trip to react to user input - just limited to a section of a page instead the whole page.
Is this what AJAX is really about?
Again - I know nothing about AJAX beyond the bits and pieces I've read - but I thought the whole point was that the UI reacts before the server round trip is made.
This is the distinction you describe in your example about a list being updated.

Full Threads Oldest First

Showing messages 1 through 1 of 1.

  • Curt Hibbs photo still confused
    2005-09-19 11:51:13  Curt Hibbs | O'Reilly AuthorO'Reilly Blogger [View]

    It does still involve a server round trip. That why it can't match the responsiveness of a desktop app, but it can be much better than without.

    In the most common case, data collected in a form is sent to the server, but it doesn't have to be form data.

    Its also possible to send and receive pure data data and transform the received data on the client side to HTML (or DOM updates). This can wring out the maximum amount of responsive. But the cost is extensive, custom, client-side javascript. A lot of work.

    This might be justified in some cases, but the built in Rails Ajax support is designed to hit the sweet spot of the common cases and requires very little effort to get there.