我正在破坏骨干网中的模型,它会发送正确的 DELETE 请求。请求一切正常;我什至检查了 chrome 调试器,在网络下它说请求status 200
尚未主干出于某种原因调用我的错误函数。这是代码:
destroy : function() {
new App.Views.Notice({ message: "Removing reminder...", type: "message"});
this.model.destroy({
success: function(model, response){
this.close();
new App.Views.Notice({message: "Successfully remove reminder", type:"success"});
},
error: function() {
new App.Views.Notice({message: "Could not remove reminder", type:"error"});
}
});
},
在我的 Rails 模型中:
def destroy
note = Note.find_by_id(params[:id])
note.destroy
end
(我应该在这里渲染一些 json 吗?)
这是请求信息:
DELETE /notes/41 HTTP/1.1
Host: 127.0.0.1:3000
Connection: keep-alive
Accept: application/json, text/javascript, */*; q=0.01
Origin: http://127.0.0.1:3000
X-Requested-With: XMLHttpRequest
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.43 Safari/537.31
Referer: http://127.0.0.1:3000/
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3
Cookie: _Notely_session=BAh7B0kiD3Nlc3Npb25faWQGOgZFRkkiJTc1MTk3OGRkYzNiZGUzODY1YjYyYWM2MmNjOWZjZDViBjsAVEkiEF9jc3JmX3Rva2VuBjsARkkiMXNUWGZDUkpHL1F2Um52NXB0emNsNnpmWDVVS1dmZ1RLOUtkQk9STXA2UjA9BjsARg%3D%3D--b186601186315cb3cc7aee51b92d1e2a76a8279e
回复信息:
HTTP/1.1 200 OK
Content-Type: text/html; charset=utf-8
X-Ua-Compatible: IE=Edge
Cache-Control: no-cache
X-Request-Id: 94ab62df5f0b462901174ae329d37e1f
X-Runtime: 0.088005
Server: WEBrick/1.3.1 (Ruby/1.9.3/2013-01-15)
Date: Thu, 28 Mar 2013 04:25:34 GMT
Content-Length: 0
Connection: Keep-Alive
Set-Cookie: _Notely_session=BAh7BkkiD3Nlc3Npb25faWQGOgZFRkkiJTA1YWViMDI2NmZjMjI3NDM4ZDcwZjBkZjhjNWVjYzFiBjsAVA%3D%3D--507388d81c70eb937fe521749b60e7f170d15671; path=/; HttpOnly
在 Chrome 调试器的响应选项卡下,它还显示“此请求没有可用的响应数据”我应该在 Rails 中发送一些东西吗?如果是这样,是什么?