我想更新我的rails应用程序中的div。 Iam刚刚学习ROR。所以它是我的学习舞台,请找到代码。 鉴于网页...Ruby on Rails + Ajax
<%= javascript_tag do %>
jQuery(function($)
{
$("#tabs4").click(function()
{
$.ajax(
{
url:'/spaces/showcal',
type:'GET'
});
});
});
<% end %>
在空间控制器..
def showcal
respond_to do |format|
format.html
{
render (:update) { |page|
page.replace_html 'tab4', :partial => 'spaces/showcal'
}}
end
end
我在做什么错在这里。请帮忙 我也有一个泛音页面(_showcal),其中有一些文本显示到该div。
反正。你能告诉我为什么我们应该使用respond_to do | format | format.html format.js – rubyist
format.html和format.js是一种响应不同响应类型的方法。也许你想渲染或返回一些有所不同,取决于预期的格式。如果你没有respond_to块,你的控制器动作就会变成你正在进行的渲染方法调用,因为它每次只会执行一步。 – agmcleod