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