Ajax

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 ?’ %>

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…

On Mon, Dec 10, 2012 at 6:23 AM, Werner
[email protected] 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!