Reputation: 13308
The code below is not working for some reason. As I click at "test" it redirects me to /home/test and shows nothing.
view/home/index.html.erb
<%= link_to "test", { :controller => "home", :action => "test" }, :remote => true %>
<div id='test_div'>
</div>
view/home/index.js.erb
$("#test_div").html("some text");
controller
class HomeController < ApplicationController
def test
"test123 test456"
respond_to() do |format|
format.js {render :layout => false}
end
end
end
What should I do to refresh div_test using ajax?
Upvotes: 0
Views: 795
Reputation: 3526
What does your routes file look like? Can you post it on here? Do a rake routes and post the output.
Here are some things that may help you:
link_to_remote
function is not in Rails. What version of rails are you on? Bash: $ rails -v
Edit: looking over this again, I dont think you need ()
after respond_to
or the {...}
in link_to
. Look at the third link. I think you need to put the page in a partial and render it. Its not rendering right now since its render :layout => false
Upvotes: 1