简体   繁体   中英

Backbone.js PUT/DELETE problems with Codeigniter REST server

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

我也遇到了这个问题,并提出了一些解决问题的更改: 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:

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

Hope that solves it. Cheers!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM