Forum: Ruby on Rails ajax..

Posted by Werner (Guest)
on 2012-12-11 18:18
(Received via mailing list)
Hope it is o.k. when I post a js/ ajax related to rails.. question here.

I have a form with a select field.
What I have in mind is to display an inline div with some db related 
infos
when the select_field has changed.

form
<%= f.collection_select :parent_id, Project.all, :id, :project_name,
:include_blank => 'Part Project ?' %>

<div id="mydiv" style="display:none"></div>

js

$(document).ready(function() {
$("select#project_parent_id").bind("change",function() {
var id = $(this).children(":selected").val();
var params = 'find_id=' + id;

$.ajax({
type: 'get',
url: "find_project",
data: params,

success : function(data) {
$("div#mydiv").show();
$("div#mydiv").html(data.name)
}
})
})
})

controller

def find_project
    @project = Project.find(params[:find_id])
end

result..in console GET 
http://0.0.0.0:3000/projects/find_project?find_id=1404 (Not Found)

Some help would be great..
Posted by Jordon Bedwell (Guest)
on 2012-12-11 18:24
(Received via mailing list)
On Mon, Dec 10, 2012 at 6:23 AM, Werner 
<webagentur.laude@googlemail.com> wrote:
> Hope it is o.k. when I post a js/ ajax related to rails.. question here.
>
> I have a form with a select field.
> What I have in mind is to display an inline div with some db related infos
> when the select_field has changed.

__SNIP__

> result..in console GET http://0.0.0.0:3000/projects/find_project?find_id=1
> 404 (Not Found)
>
> Some help would be great..

Show us your routes!
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.