I am not familiar with ajax and ruby on reiki. I myself learned to do a project.
Now I am facing a problem, I want to use ajax to retrieve data from the controller.
I am 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 (a book is one of my tables)
this code works, but instead of extracting all the data from the books, I want only part of it. let's say some data in an action test in my book controller
def test @test=books.find.last respond_do |format| format.html format.json {render ;json=>@test} end end
but when I change the URL to books / test, I get an error: 404 not found in the console log.
How can I get some of the controller data? thank you in advance
user4029440
source share