Edited I add the ajax where I make the request
$.ajax({
//tipo de peticion puede ser
type: "POST",
//url del php
url: "pcService.php",
//separado por comas
data: {
id: idPC,
comando: 1,
},
//tipo de dato a recibir
dataType: "json",
//en el caso de algun error que mande un mensaje
error: function (jqXHR, textStatus, errorThrown) {
swal(
'Error!',
errorThrown,
'error'
);
},
//si hay conexion obtenemos la data que nos envia el php
success: function (data, textStatus, jqXHR) {
console.log(data);
}
});
I have the following function.
$comando = $_POST["comando"];
switch ($comando){
case 1:
//get Asignaciones
$idPc = $_POST["id"];
echo asignacionPcLista($idPc);
break;
}
function asignacionPcLista($idPc){
GLOBAL $bd;
try {
$arrayInfo = array();
$conexion = $bd->getConecction();
$query = "SELECT sp.nombre,ac.fecha FROM soporte_compu AS c
INNER JOIN soporte_asignacion_compu AS ac ON ac.SOPORTE_COMPU_idSOPORTE_COMPU = c.idSOPORTE_COMPU
INNER JOIN soporte_personal AS sp ON sp.idSOPORTE_PERSONAL = ac.SOPORTE_PERSONAL_idSOPORTE_PERSONAL
WHERE c.idSOPORTE_COMPU = ? AND ac.status = ?";
$stmt = $conexion->prepare($query);
$stmt->bind_param("is", $idPc,$estatus = '1');
$stmt->execute();
$resultSet = $stmt->get_result();
$stmt->close();
array_push($arrayInfo,["asignaciones"=>$resultSet->fetch_array(MYSQLI_ASSOC)]);
//array_push($arrayInfo,["informacion"=>getPC($idPc)]);
return json_encode($arrayInfo, true);
} catch (mysqli_sql_exception $e) {
return json_encode(["error" => "Error al modificar la asignación, " . $e->getMessage()], true);
}
}
This sentence gets me all the users that have a pc assigned. When it comes to a user if I throw the data well, the detail is in that when more than one for example: 5 users do not throw anything at me.
Here I show the result that should be waiting, but when I want to get it in php does not throw anything at me, only throws when there is a user in that assignment but when many are assigned does not show me anything.