# How to route to an action with ajax.request

**URL:** <https://www.ruby-forum.com/t/how-to-route-to-an-action-with-ajax-request/147850>\
**Category:** Rails\
**Created:** [September 6, 2008, 1:44am UTC](https://www.ruby-forum.com/t/how-to-route-to-an-action-with-ajax-request/147850 "2008-09-06T01:44:41Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![paradise](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/8e7dd6/32.png) [@paradise](https://www.ruby-forum.com/u/paradise)\
**Post date:** [September 6, 2008, 1:44am UTC](https://www.ruby-forum.com/t/how-to-route-to-an-action-with-ajax-request/147850/1 "2008-09-06T01:44:41Z")

</div>

Hi, so I am attempting to gather a number of onclicks from the user  
with a javascript function and store them in an array. The problem is  
that I now want to be able to take that array and covnert it into ruby  
so that I can perform further functions on it and save it in the  
database. This is the function that I have so far: I am using JSON  
and trying to pass the array in an ajax.request call but it is not  
routing to the /appointments/array/ action. Is this the right way to  
go about it?

```
    function test()
    {
          for(i=1;i<22;i++){
                if (document.getElementById(i+'d').className ==

```

“selected”){  
myArray.push(i);  
}  
}

```
            new Ajax.Request('/appointments/array/',

```

{method:‘post’,postBody:‘data=’+myArray.toJSON});  
}
