Backbone.js Codeigniter REST 服务器的 PUT/DELETE 问题
相关
注意:这个问题与 CodeIgniter-RestServer当我从主干调用 model.save() 时 路由 put 请求的函数不会获取任何 PUT 数据。 Firebug 显示正在发送的正确 PUT 参数。然而 $this->put('keyname') 总是返回 false。这意味着 CI 的 REST 服务器无法找到应有的 PUT 数据。
另一方面,如果我设置:
Backbone.emulateJSON = true;
我可以工作,因为 Backbone 将在名为“model”的单个属性下发送所有 PUT 数据,使用这种方式 $this->put('model'); :
那么所涉及的额外努力是
$data = json_decode($this->put('model'),true); // to get normal behavior #sucks
NOTE: This question is related to CodeIgniter-RestServer
When I call model.save() from backbone the function where the put request is routed doesn't gets any PUT data. Firebug shows right PUT parameters being sent. However $this->put('keyname') always returns false. Which means CI's REST Server can't find PUT data as it should.
On the other hand, If I set:
Backbone.emulateJSON = true;
I can work, as then Backbone will send all PUT data under a single attribute named "model", using this way $this->put('model'); works
Then the extra effor involved is:
$data = json_decode($this->put('model'),true); // to get normal behavior #sucks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我也遇到了这个问题,并进行了一些更改来解决该问题:
https://github.com/philsturgeon/codeigniter-restserver/pull/84
I was running into this issue as well and pushed a few changes that fix the problem:
https://github.com/philsturgeon/codeigniter-restserver/pull/84
过去已经解决过这个问题。解决这个问题的方法是在你的函数中使用它:
希望能解决它。干杯!
have been through this problem already in the past. Solution to this problem is to use this inside your functions:
Hope that solves it. Cheers!