1
How to list these data from Sponse, mainly IMG, follows the data BELOW:
$data = file_get_contents("php://input"); $objData = json_decode($data); $categoria = $objData->categoria->name_categoria; $titulo = $objData->titulo; $texto = $objData->texto; $data = $objData->data; $autor = $objData->autor; $status = $objData->status; $img = $objData->img->name;
{ [functions]: , __proto__: { }, autor: "Luquinhas Brito", categoria: { [functions]: , __proto__: { }, date_categoria: "12/04/2017", id_categoria: 1, name_categoria: "Geral", status_categoria: "1", type_categoria: "news" }, data: "26/04/2017", img: { [functions]: , __proto__: { }, lastModifiedDate: [date] Mon Jul 18 2016 20:53:17 GMT-0300 (Hora oficial do Brasil), name: "Capturar.JPG", size: 78623, type: "image/jpeg", webkitRelativePath: "" }, status: "1", texto: "..", titulo: "Titulo Test" }
Follow the error:
( ! ) Notice: Undefined property: stdClass::$name in C:\wamp64\www\Projeto_Sara\pages\admin\server-processing\cadastrarNews.php on line 12 Call Stack #TimeMemoryFunctionLocation 10.0005396592{main}( )...\index.php:0 20.0013432280router->routing( )...\index.php:69 30.03731824648require( 'C:\wamp64\www\Projeto_Sara\pages\admin\server-processing\cadastrarNews.php' )...\router.class.php:100
json_decode on it! 11
– rray
No list, the img
– Luquinhas Brito
$data = file_get_contents("php://input");
 $objData = json_decode($data);

 $categoria = $objData->categoria->name_categoria;
 $titulo = $objData->titulo;
 $texto = $objData->texto;
 $data = $objData->data;
 $autor = $objData->author; $status = $objData->status; $img = $objData->img->name;
– Luquinhas Brito
Where did you get this data in json? And how do you send it to javascript?
– Juven_v
A tip: Use the second parameter of the json_decode($json, true) function, as true so that the json_decode result is an array for easy data visualization.
– girorme