我与参数的命令一个简单的形式。当我的下拉改变时,我称之为:
I have a simple form with an order by param. When my dropdown is changed, I call this:
$.post("/busca", $("#order_form").serialize(), dataType: "script")
在轨控制器身边,我有一个简单的 format.js
来处理Ajax调用。
事情是,这是行不通的。该 js.erb
模板永远不会呈现。
On the rails controller side I have a simple format.js
to handle the ajax calls.
Thing is that this isn't working. The js.erb
template is never rendered.
我的日志显示处理由BuscaController#指数为* / *
,我不知道是什么 * / *
表示。有人可以帮我吗?
My log shows Processing by BuscaController#index as */*
and I have no idea what the */*
stands for. Can someone help me?
好了,所以我想它了。当你有一个respond_to代码块这样的:
Ok so I figured it out. When you have a respond_to block like this:
respond_to do |format|
format.html
format.js
end
这是行不通的。您需要设置的js第一反应比HTML之一。不要问我为什么。 这是一个对我的作品:
It will not work. You need to setup the js response first than the HTML one. Don't ask me why. This is the one that works for me:
respond_to do |format|
format.js
format.html
end