Backbone.js Codeigniter REST 服务器的 PUT/DELETE 问题

发布于 2024-12-18 11:08:48 字数 574 浏览 0 评论 0原文

相关

注意:这个问题与 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

云仙小弟 2024-12-25 11:08:48

我也遇到了这个问题,并进行了一些更改来解决该问题:
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

离线来电— 2024-12-25 11:08:48

过去已经解决过这个问题。解决这个问题的方法是在你的函数中使用它:

$data = $this->request->body;
echo $data['id'];

希望能解决它。干杯!

have been through this problem already in the past. Solution to this problem is to use this inside your functions:

$data = $this->request->body;
echo $data['id'];

Hope that solves it. Cheers!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文