Backbone.js PUT/DELETE problems with Codeigniter R

2020-07-30 01:55发布

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

2条回答
女痞
2楼-- · 2020-07-30 02:36

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

查看更多
神经病院院长
3楼-- · 2020-07-30 02:46

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!

查看更多
登录 后发表回答