I'm new to backbone and trying to write an html5 front end for an existing (and pretty big) REST back end. I found that when saving a model, backbone by default sends the model encoded as JSON which my existing API doesn't support. Is it possible to send plain simple post request with variables using backbone?
Asked
Active
Viewed 4,045 times
4
-
duplicated? http://stackoverflow.com/questions/5096549/how-to-override-backbone-sync – fguillen May 10 '12 at 10:42
-
2It's duplicated, but phrased very differently, so if the poster searched for their own problem, they wouldn't necessarily find the answer. It actually points to a big problem with technical searches - if you don't use the right terms, you won't find an easily found resource (so then it's not easily findable for you). – Peter Hanley Nov 24 '12 at 15:07
1 Answers
4
I think what you're looking for is Backbone.emulateJSON = true
copied from the official documentation:
If you're working with a legacy web server that can't handle requests encoded as application/json, setting Backbone.emulateJSON = true; will cause the JSON to be serialized under a
model
parameter, and the request to be made with a application/x-www-form-urlencoded mime type, as if from an HTML form.

Evan Carroll
- 78,363
- 46
- 261
- 468

Vincent Briglia
- 3,068
- 17
- 13
-
This is still not really using what I think of as post variables. It's stuffing a JSON object into a "model" variable.. – Evan Carroll Apr 06 '15 at 20:51