# To ajax or not to ajax

**URL:** <https://www.ruby-forum.com/t/to-ajax-or-not-to-ajax/94207>\
**Category:** Rails\
**Created:** [April 25, 2006, 4:26pm UTC](https://www.ruby-forum.com/t/to-ajax-or-not-to-ajax/94207 "2006-04-25T16:26:20Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![orotone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/90db22/32.png) [@orotone](https://www.ruby-forum.com/u/orotone)\
**Post date:** [April 25, 2006, 4:26pm UTC](https://www.ruby-forum.com/t/to-ajax-or-not-to-ajax/94207/1 "2006-04-25T16:26:20Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![orotone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/90db22/32.png) [@orotone](https://www.ruby-forum.com/u/orotone)\
**Post date:** [April 25, 2006, 4:38pm UTC](https://www.ruby-forum.com/t/to-ajax-or-not-to-ajax/94207/2 "2006-04-25T16:38:44Z")

</div>

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](http://www.height1percent.com/articles/2006/04/21/improving-debugging-for-ajax-and-rjs)

Cheers,  
Marco

---

<div class="post-metadata">

**Author:** ![orotone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/90db22/32.png) [@orotone](https://www.ruby-forum.com/u/orotone)\
**Post date:** [April 25, 2006, 4:54pm UTC](https://www.ruby-forum.com/t/to-ajax-or-not-to-ajax/94207/3 "2006-04-25T16:54:10Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![orotone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/90db22/32.png) [@orotone](https://www.ruby-forum.com/u/orotone)\
**Post date:** [April 25, 2006, 5:22pm UTC](https://www.ruby-forum.com/t/to-ajax-or-not-to-ajax/94207/4 "2006-04-25T17:22:06Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![orotone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/90db22/32.png) [@orotone](https://www.ruby-forum.com/u/orotone)\
**Post date:** [April 25, 2006, 6:30pm UTC](https://www.ruby-forum.com/t/to-ajax-or-not-to-ajax/94207/5 "2006-04-25T18:30:46Z")

</div>

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](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.

---

<div class="post-metadata">

**Author:** ![orotone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/90db22/32.png) [@orotone](https://www.ruby-forum.com/u/orotone)\
**Post date:** [April 25, 2006, 6:48pm UTC](https://www.ruby-forum.com/t/to-ajax-or-not-to-ajax/94207/6 "2006-04-25T18:48:33Z")

</div>

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](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.

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

Best regards

Peter De Berdt
