【发布时间】:2013-07-28 14:31:00
【问题描述】:
我在 Rails 应用程序中的 ajax 请求遇到了一些问题。
我提出一个请求,当我点击时我从链接中获取一些参数,然后我想刷新包含我数据库中的图像的部分。
这是我的ajax
$.ajax({
url:"gallery",
data: { pie :categoria},
type: "GET",
async: true,
dataType: "script"
});
问题是在 rails shell 中我的参数被传递了。 但它不会对视图进行任何更改。
我的外壳:
Started GET "/gallery?pie=VibPellizcables&_=1375047201412" for 127.0.0.1 at Sun Jul 28 18:33:21 -0300 2013
Processing by GalleryController#pro as JS
Parameters: {"pie"=>"VibPellizcables", "_"=>"1375047201412"}
Product Load (0.1ms) SELECT `products`.* FROM `products` WHERE `products`.`pie` = 'VibPellizcables'
Rendered sexytoys/_algo.html.haml (0.1ms)
Completed 200 OK in 1ms (Views: 0.6ms | ActiveRecord: 0.1ms)
我想更新一个包含我的数据库中的图像的部分。
这是我要更新的部分。
#miniDiv
%ul#miniRecuadro
- @products.each do |product|
%li.mini= image_tag product.pic.url(:thumb)
我的控制器:
def gallery
@products = Product.find(:all, :conditions => {:pie => params[:pie]})
#render :partial => "algo"
flash[:notice] = "Mensaje ENVIADO >>"
respond_to do |format|
format.js {render :partial => 'algo', :conditions => {:pie => params[:pie]}}
# format.json { render :json => @products }
end
【问题讨论】:
标签: ruby-on-rails ajax refresh