# Ajax POST from Javascript to Rails: How?

**URL:** <https://www.ruby-forum.com/t/ajax-post-from-javascript-to-rails-how/178163>\
**Category:** Rails\
**Created:** [October 30, 2009, 3:11am UTC](https://www.ruby-forum.com/t/ajax-post-from-javascript-to-rails-how/178163 "2009-10-30T03:11:26Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![kbkbkb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/aeb1de/32.png) [@kbkbkb](https://www.ruby-forum.com/u/kbkbkb)\
**Post date:** [October 30, 2009, 3:11am UTC](https://www.ruby-forum.com/t/ajax-post-from-javascript-to-rails-how/178163/1 "2009-10-30T03:11:26Z")

</div>

Hi,

I’m new to rails, and have been struggling for a while now on how to  
get a simple HTTP POST working via a Prototype-based Ajax call to a  
rails scaffold. I’m performing the POST as follows from javascript:

new Ajax.Request(‘object/create’, {  
method: ‘post’,  
parameters: {object : {url: murl, title: mtitle }},  
…

… but my rails application doesn’t actually see any of the  
parameters I’m sending (i.e. url, title).

This leads me to suspect that the way I’m formatting my parameters is  
wrong, but I can’t seem to find any examples of how to do something  
like this on the web. Can someone help point me in the right direction  
here?

Thanks.

---

<div class="post-metadata">

**Author:** ![kbkbkb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/aeb1de/32.png) [@kbkbkb](https://www.ruby-forum.com/u/kbkbkb)\
**Post date:** [October 30, 2009, 6:18am UTC](https://www.ruby-forum.com/t/ajax-post-from-javascript-to-rails-how/178163/2 "2009-10-30T06:18:49Z")

</div>

> new Ajax.Request(‘object/create’, {  
> method: ‘post’,  
> parameters: {object : {url: murl, title: mtitle }},

Hi  
There are various prototype helpers which does this job for you.  
You can look at remote\_form\_for,submit\_to\_remote, etc at this section  
and watch the html output generated by them

[http://api.rubyonrails.org/classes/ActionView/Helpers/PrototypeHelper.html](http://api.rubyonrails.org/classes/ActionView/Helpers/PrototypeHelper.html)

Sijo
