Do not receive POST data using / json application

I use Backbone, PHP (5.6) and Apache (2.4).

Problem: When sending data using Backbone model.save (), the $ _POST array is empty on the server.

I know of various ways to fix this.

Client method: . Backbone.emulateJSON - true or change the source of the baseline.
Server-side method: reading the original body instead of $ _POST.

They work, but they feel like hacks, and in fact they turn out to be a little uncomfortable.
Also, the Backbone doc says:

If you are working with an outdated web server that cannot handle requests encoded as application / json, setting Backbone.emulateJSON = true; [fix].

So this seems like a server issue. How to make my server inapplicable?

+4
source share
1 answer

Thanks to the comments, I realized that this is the correct behavior.

$ _ POST is for form data, while json (application / json) data must be obtained from the original input.

+1
source

All Articles