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