2
我有一个令人困惑的问题与Rails 3.2.6和JQuery 1.7.2。为什么我的POST请求被解释为GET?
我一直在尝试向我的服务器发出POST请求,但由于某些原因,只有GETs出现在我的日志中。
例如,当我在我的JavaScript控制台输入这个...
$.ajax({
type: 'POST',
url: 'trials'
});
...我的日志显示此:
Started GET "/trials" for 127.0.0.1 at 2012-07-21 21:43:17 -0400
Processing by TrialsController#index as JSON
Trial Load (0.2ms) SELECT "trials".* FROM "trials"
Completed 200 OK in 88ms (Views: 2.7ms | ActiveRecord: 1.1ms)
我检查rake routes
,但明确表示登载有应该去trials#create
,不trials#index
:
trials GET /trials(.:format) trials#index
POST /trials(.:format) trials#create
new_trial GET /trials/new(.:format) trials#new
edit_trial GET /trials/:id/edit(.:format) trials#edit
trial GET /trials/:id(.:format) trials#show
PUT /trials/:id(.:format) trials#update
DELETE /trials/:id(.:format) trials#destroy
我是网络开发新手......所以...帮助!
这是怎么回事?
为什么地球上我的POSTs
被转换为GETs
?
那么,你的请求是作为'POST'吗?使用浏览器工具,Fiddler或Wireshark进行验证。 – Brad 2012-07-22 02:01:29