I am not familiar with ajax nor ruby on rails.I've been self learn to do project.
Now I face a problem,I want to use ajax to retrieve data from controller.
I'm not sure how to write the url part:
$.ajax({
type:"GET",
url:"books",
dataType:"json",
success:function(result){
alert(result);
}
})
books is the name of my controller(book is one of my table)
this code works,but instead of retrieve all data from books,I only want a part of it. say some data in action test in my books controller
def test
@test=books.find.last
respond_do |format|
format.html
format.json {render ;json=>@test}
end
end
but when I change url to books/test,I'll get a error message say 404 not found in console log.
How can I retrieve part of controller data?thanks in advance