I need to parse two jsons I have it like this but I get an error.
The variable obj.descripcion
does not give me an error if it sent one but when it sent two it gives me an error.
json that PHP returns and I capture in response
{"descripcion_necesidad":"plplpplpl","id_necesidad":"15"}
{"descripcion_necesidad":"Necesidad por drogas","id_necesidad":"19"}
javascript
var obj = JSON.parse(respuesta);
console.log(obj.descripcion_necesidad);
PHP here I return the value
public static function buscarFocoController($datos){
$respuesta = ideasModels::buscarFocoModels($datos,$_SESSION["id"]);
$longitud = count($respuesta);
for($i=0; $i<$longitud; $i++)
{
echo json_encode($enviarDatos = array(
"descripcion_necesidad"=>$respuesta[$i]["descripcion_necesidad"],
"id_necesidad"=>$respuesta[$i]["id_necesidad"],
));
}
}