Coder Perfect

How can I get the payload of a request?


PHP, ExtJS, and ajax store are the tools I’m utilizing.

It does not use POST or GET to deliver data (on create, update, and destruct). In the “Request Payload” field of the Chrome Console, I see my outgoing parameters as JSON. Both $_POST and $_GET are null.

How can I get it in PHP?

Asked by nkuhta

Solution #1

If my understanding is correct, you’re simply delivering json data through the http body rather than application/x-www-form-urlencoded data.

This snippet will get you the data you need:

$request_body = file_get_contents('php://input');

If you’re passing json, you can use the following syntax:

$data = json_decode($request_body);

The json data is then stored in a php array called $data.

A wrapper is something like php:/input.

Answered by Ikke

Solution #2

Also, if you set encode: true on extJs writer, it will send data on a regular basis (and thus you will be able to receive data via $_POST and $_GET).


Also, according to doctors:

As a result, the root config of the writer is most likely necessary.

Answered by Molecular Man

Post is based on