我正在向我的 Rails 应用程序发送发布请求:
$.ajax
url: "/" + locale + "/administration/dashboards/remove_tag_named.json"
type: "POST"
dataType: "json",
contentType: "json"
data: {"tag_name": "bingo" }
success: (result) ->
.....
我可以在控制台中看到帖子,但我没有成功,在帖子之后我看到列出了很多 GET 请求
[19:37:00.052] POST http://localhost:3000/fr/administration/dashboards/remove_tag_named.json [HTTP/1.1 301 Moved Permanently 42ms]
Started GET "/fr/administration%2Fdashboards%2Fremove_tag_named.json" for 127.0.0.1 at 2013-01-16 19:32:31 +0100
Started GET "/fr/administration%2Fdashboards%2Fremove_tag_named.json" for 127.0.0.1 at 2013-01-16 19:32:31 +0100
....
在我的 Rails 应用程序中,我有
respond_to :html, :json
.....
def remove_tag_named
# should remove the tag from the table
respond_to do |format|
format.html { redirect_to administration_dashboards_url, notice: t(:tag_deleted) }
format.json { head :no_content }
end
end
有什么问题?是 jQuery ajax 请求还是 Rails 响应?如果我尝试在我的 Rails 操作中插入一个调试器,什么都不会发生..
I have checked my routes and it's ok :
remove_tag_named_administration_dashboards_fr POST /fr/administration/console/remove_tag_named(.:format) administration/dashboards#remove_tag_named {:locale=>"fr"}
remove_tag_named_administration_dashboards_en POST /en/administration/dashboards/remove_tag_named(.:format) administration/dashboards#remove_tag_named {:locale=>"en"}