【发布时间】:2014-02-12 12:44:50
【问题描述】:
经过一番努力,我设法使 ajax 工作:
你好.js.erb:
$("#show_hosts").html("some text");
testQueuesController.rb:
class testQueuesController < ApplicationController
def index
@test_queues = testQueue.all
respond_to do |format|
format.html
format.json { render json: @test_queues }
end
end
end
视图中的相关部分:
<%= link_to "hello", { :controller => "kashmir_queues", :action => "hello" }, :remote => true %>
现在,这是可行的,但我真正想做的是现在加载“一些文本”,但要加载另一个我命名为 show_hosts.html.erb 的视图,我该怎么做?
【问题讨论】:
-
您的问题不清楚,您所说的“现在正在加载”某些文本“是什么意思,但要加载我命名为 show_hosts.html.erb 的另一个视图”
-
我想加载一个名为 show_hosts.erb 的视图,它将替换 div .. 此刻我放置的硬编码文本。
标签: jquery html ruby-on-rails ajax