benpickles / js-model

Work with models in your JavaScript
http://benpickles.github.io/js-model/
MIT License
403 stars 42 forks source link

Model.save() and REST persistence #23

Closed mdings closed 12 years ago

mdings commented 12 years ago

Hi Ben,

Thanks for sharing js-model, it's very nice to work with.

I am facing an issue however that might look simular to this one: https://github.com/benpickles/js-model/issues/16, though I am not completely sure.

When I update the attributes of an existing model and call save afterward a put request is sent to the server. All is well but it seems like the request is not properly encoded. When I open up my Chrome developer tools and take a closer look in the headers section of the network tab, I can see that the data is sent as "request payload" rather than the expected "form data". Also this post (http://stackoverflow.com/questions/10494574/what-is-the-difference-between-form-data-and-request-payload) pushed me somewhat in the right direction, although I could not find the exact solution.

Regards,

Maarten

mdings commented 12 years ago

I' am using Slim Framework for my backend. It seems that it interprets form data differently than request payload. The first can be read by using $app->request()->post(), the latter by using $app->request()->getBody() and applying json_decode(). Closing the issue..