$_POST only works if you send data in an encoded form. You are sending JSON, so PHP cannot parse it into the $_POST array.
You need to read directly from the POST body.
$post = fopen('php://input', r); $data = json_decode(stream_get_contents($post)); fclose($post);
source share