# Ajax responses

**URL:** <https://www.ruby-forum.com/t/ajax-responses/103364>\
**Category:** Radiant CMS\
**Created:** [May 4, 2007, 7:47pm UTC](https://www.ruby-forum.com/t/ajax-responses/103364 "2007-05-04T19:47:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Benjamin\_C](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/85e7bf/32.png) [@Benjamin\_C](https://www.ruby-forum.com/u/Benjamin_C)\
**Post date:** [May 4, 2007, 7:47pm UTC](https://www.ruby-forum.com/t/ajax-responses/103364/1 "2007-05-04T19:47:31Z")

</div>

I’m doing a custom page, and I’d like to respond to some Ajax  
requests in my custom process method. I haven’t been able to find an  
example of this yet, and I’m wondering if anyone who has done it  
would like to volunteer a snippet of code as a guide.

–  
Building an e-commerce site with Rails?  
[http://agilewebdevelopment.com/rails-ecommerce](http://agilewebdevelopment.com/rails-ecommerce)

Meet up at RailsConf:  
[http://railsconf2007.conferencemeetup.com/](http://railsconf2007.conferencemeetup.com/)

---

<div class="post-metadata">

**Author:** ![Benjamin\_C](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/85e7bf/32.png) [@Benjamin\_C](https://www.ruby-forum.com/u/Benjamin_C)\
**Post date:** [May 4, 2007, 8:37pm UTC](https://www.ruby-forum.com/t/ajax-responses/103364/2 "2007-05-04T20:37:37Z")

</div>

On 5/4/07, Benjamin C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I’m doing a custom page, and I’d like to respond to some Ajax  
> requests in my custom process method. I haven’t been able to find an  
> example of this yet, and I’m wondering if anyone who has done it  
> would like to volunteer a snippet of code as a guide.

A “custom page” means you are extending Radiant with a custom  
controller? If  
so, implementing Ajax in your site will be trivial. Do you need help on  
the  
server side, or help with JavaScript? I can show you how to leverage the  
Prototype framework real easy.

---

<div class="post-metadata">

**Author:** ![Benjamin\_C](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/85e7bf/32.png) [@Benjamin\_C](https://www.ruby-forum.com/u/Benjamin_C)\
**Post date:** [May 4, 2007, 8:41pm UTC](https://www.ruby-forum.com/t/ajax-responses/103364/3 "2007-05-04T20:41:37Z")

</div>

On May 4, 2007, at 11:36 AM, Mislav MarohniÄ‡ wrote:

> On 5/4/07, Benjamin C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:  
> I’m doing a custom page, and I’d like to respond to some Ajax  
> requests in my custom process method. I haven’t been able to find an  
> example of this yet, and I’m wondering if anyone who has done it  
> would like to volunteer a snippet of code as a guide.
> 
> A “custom page” means you are extending Radiant with a custom  
> controller? If so, implementing Ajax in your site will be trivial.  
> Do you need help on the server side, or help with JavaScript? I can  
> show you how to leverage the Prototype framework real easy.

No, it’s not a custom controller. I may yet take that route, if I  
must, but by “custom page” I meant I have created an extension that  
has a model that inherits from Page and overrides process.

---

<div class="post-metadata">

**Author:** ![Benjamin\_C](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/85e7bf/32.png) [@Benjamin\_C](https://www.ruby-forum.com/u/Benjamin_C)\
**Post date:** [May 4, 2007, 8:48pm UTC](https://www.ruby-forum.com/t/ajax-responses/103364/4 "2007-05-04T20:48:38Z")

</div>

Ben,

Your process method will have access to the request object. If it’s an  
Ajax request, request.xhr? will return true.

Sean
