To ajax or not to ajax

before I started building my latest rails app, I made the decision to
make
good use of ajax. My reasonsing was that users would benefit from the
quicker page updates - the application provides various different types
of
insurance quotes, and has several multi-page forms and reports that can
be
drilled down 5 or 6 levels deep in some cases - so it seemed like a good
candidate for ajax

Now that I’ve started writing the thing, I’m wondering if I’ve made a
mistake. I find ajax to be difficult to test and debug, and my views
consist
pretty much entirely of partials - it’s getting hard to keep track of
them
all.

I’m just wondering how other developers decide if it’s worth going down
the
ajax route.

Hi Alan,

sure, I’m having problem too with my first applications using AJAX but
I think it’s a matter of time and experience. In the meanwhile, have a
look at the snippet of code Richard W. (of AJAX scaffold generator
fame) suggests for debugging:

http://www.height1percent.com/articles/2006/04/21/improving-debugging-for-ajax-and-rjs

Cheers,
Marco

On 25 Apr 2006, at 16:22, Alan B. wrote:

Now that I’ve started writing the thing, I’m wondering if I’ve made a
mistake. I find ajax to be difficult to test and debug, and my
views consist
pretty much entirely of partials - it’s getting hard to keep track
of them
all.

I’m just wondering how other developers decide if it’s worth going
down the
ajax route.

There are two things to help you: there’s a function somewhere to
turn AJAX debugging on and you should use firefox with the Firebug
extension, it will allow you to debug javascript.

Best regards

Peter De Berdt

Some paper to sketch my form and naming of DIV’s helps.

But with RJS its pretty simple.

Love it. And now in the controllers.

That saves a lot of rjs templates

Peter De Berdt wrote:

On 25 Apr 2006, at 16:22, Alan B. wrote:

Now that I’ve started writing the thing, I’m wondering if I’ve made a
mistake. I find ajax to be difficult to test and debug, and my
views consist
pretty much entirely of partials - it’s getting hard to keep track
of them
all.

I’m just wondering how other developers decide if it’s worth going
down the
ajax route.

There are two things to help you: there’s a function somewhere to
turn AJAX debugging on and you should use firefox with the Firebug
extension, it will allow you to debug javascript.

Best regards

Peter De Berdt

Definately Firebug. It absolutely rocks. You can see every ajax
request, and its response, as well as inspect the DOM and has great
javascript error ctaching and debugging.

Also set this in your config/environments/development.rb

RJS Error reporting

config.action_view.debug_rjs = true

And any ajax request that generates an error will do an “alert(…info
about error…);” so you get immedaite feedback about what went wrong.

And check out the presenatation slides here:
http://mir.aculo.us/articles/2006/04/15/slides-from-my-rails-ajax-presentation-at-canada-on-rails
They taught me everything I just told you.

On 25 Apr 2006, at 18:30, Alex W. wrote:

all.

And any ajax request that generates an error will do an “alert(…info
about error…);” so you get immedaite feedback about what went wrong.

And check out the presenatation slides here:
mir.aculo.us JavaScript with Thomas Fuchs » Blog Archive » Slides from my Rails Ajax presentation at Canada on Rails
presentation-at-canada-on-rails
They taught me everything I just told you.

That’s what I was trying to say, but being to lazy to type and look
it up, thanks for filling that in :wink:

Best regards

Peter De Berdt