angularjs - file_get_contents in php returns empty string
one text
Solution:
You're literally sending "123" by itself to the server. That isn't JSON, and it isn't an object, it's just a plain string.
So I suggest
remove
headers: { 'Content-type': 'application/json;charset=utf-8' }
from the $http options,change
$data = json_decode(file_get_contents("php://input"));
to just$id_del = file_get_contents("php://input");
remove
$id_del = $data->send_id;
change
if(is_null($data)){
toif(is_null($id_del)){
and changevar_dump($data);//empty string if(count(array($data)) > 0) {
tovar_dump($id_del);//empty string if(!empty($id_del) {
This will make PHP read just the plain string and use that as the ID, without attempting to decode it as JSON or extract values from within it.
Source