【发布时间】:2014-05-18 10:58:43
【问题描述】:
通过我的表 (id = "portfolios"),点击一个 cel,我将值发送到我的 rails 控制器 /game/search。
此查询工作正常,但整个页面正在重新加载。我只想重新加载表。有什么办法吗?
function getval(cel) {
if (isNaN(cel)==true){
window.alert("Oops! Click again.");
}
else {
c="<% cut_line %>";
jQuery.ajax({
data: 'q=' + cel,
//dataType: 'script',
type: 'post',
url: "/game/search"
});
//post_to_url("/game/search", {q: cel});
}
}
这是控制器动作:
def search
Game.new.update_matrix(params[:q], Ip.where(ip: request.remote_ip).last)
redirect_to :action => :play
end
【问题讨论】:
-
你能粘贴你的控制器动作吗?
标签: jquery html ruby-on-rails ajax refresh