Ruby on rails rails简单ajax请求

Ruby on rails rails简单ajax请求,ruby-on-rails,ajax,Ruby On Rails,Ajax,我对ajax请求有问题: 在我的应用程序中,我试图配置一个简单的排名系统,并对其进行了设置,但当我点击排名按钮时,我会重新加载页面并刷新排名 帮助我的同事认识到在ajax中: 我做到了: 在posts/show.html.erb中,我有: <div id='vote_update'> <%= render 'vote/update' %> </div> 在vote/update.js.erb中,我有: $('#vote_updat

我对ajax请求有问题:

在我的应用程序中,我试图配置一个简单的排名系统,并对其进行了设置,但当我点击排名按钮时,我会重新加载页面并刷新排名

帮助我的同事认识到在ajax中:

我做到了:

posts/show.html.erb
中,我有:

    <div id='vote_update'>
      <%= render 'vote/update' %>
    </div>
vote/update.js.erb
中,我有:

$('#vote_update').html("<%= j render('vote/update') %>");
如果我删除了romete:true-一切正常(页面重新加载,我看到(:注意)“你的投票计数!”并且评级更新,但是如果我将remote:true放回,我什么也看不到(firebug控制台中出现了一些错误)-但是当我重新加载页面时-ratign更新了,我看到了正常结果-我想我在重定向方面犯了一些错误,或者我不知道

请帮我换衣服

respond_to do |format|
    if vote.save
      format.html { 
        redirect_to post_path(post),
        :notice => "You vote counted!"
      }
      format.js
    end
end
到 如果投票,请保存 回应待办事项|格式|

      format.html { 
        redirect_to post_path(post),
        :notice => "You vote counted!"
      }
      format.js
    end
end
虽然改变了,但不确定

respond_to do |format|
    if vote.save
      format.html { 
        redirect_to post_path(post),
        :notice => "You vote counted!"
      }
      format.js
    end
end
到 如果投票,请保存 回应待办事项|格式|

      format.html { 
        redirect_to post_path(post),
        :notice => "You vote counted!"
      }
      format.js
    end
end

不确定您的ajax代码是否为format.js块。您可以在其中更新显示排名的html。

您的ajax代码将为format.js块。您可以在其中更新显示排名的html。

您的ajax代码将为format.js块。您可以在其中更新显示排名的htmlrank.您的ajax代码将以format.js块的形式出现。您可以在其中更新显示排名的html。我不太明白您的意思,您在问题中描述了我试图做什么-当我单击submit btn时,我向vote/update.js.erb发送请求,并在那里尝试更新我的$(“#vote_update”)-div block,但在我的问题中,我有一些错误,我不知道我在哪里错过了那部分,在你的update.js.erb中,你可以让js更新排名,并显示flash message不,你是对的,我渲染-但渲染不是我需要的=)谢谢=)我不太明白你的意思,你在问题中描述了我试图做什么-当我点击提交btn时,我向vote/update.js.erb发送了一个请求,在那里我尝试更新我的$(“#vote_update”)-div块,但在我的问题中我有一些错误,我不知道我错过了那部分,在你的update.js.erb中,你可以让js更新排名,还可以显示flash message不,你是对的,我渲染-但渲染不是我需要的=)谢谢=)