0
I have the following code:
$.ajax({
type:"post",
url:"../connect/post/infoClienteTask.php",
data:'infoClienteTask='+fantasy,
success:function(responseData){
console.log(responseData);
$(".historic-cliente").html('<li class="list-group-item">'+responseData.Project+' - '+responseData.Delivery+'</li>');
}
});
That by clicking on a customer list, it shows all the customer history, but with this code I can only find the first one in the search.
In PHP I have the following codes.
POST:
header( 'Content-Type: application/json; charset=UTF-8' );
$selInfoClienteTasks= new Tasks();
if($_SERVER['REQUEST_METHOD']=='POST'){
$fantasy = $_POST['infoClienteTask'];
$stInfoClienteTasks = $selInfoClienteTasks->selectInfoClienteTask($fantasy);
echo json_encode($stInfoClienteTasks);
exit();
}
SELECT:
public function selectInfoClienteTask($fantasy){
try {
$stmt = $this->conn->prepare("SELECT tasks.*, DATE_FORMAT( tasks.Delivery , '%d/%m/%Y' ) as Delivery FROM Tasks WHERE CompanyFantasy = '$fantasy'");
$stmt->execute();
return $stmt->fetch(PDO::FETCH_ASSOC);
}catch (PDOException $exception){
header("Location: ./error.php?err=Unable-to-find-info");
echo 'Error: '.$excption->getMessage();
return null;
}
}
I need to make a While/Foreach/For in this Ajax to continue searching until you find all the information, someone has an idea?
What gives this one
console.log(responseData);
? or better:console.log(JSON.stringify(responseData));
– Sergio
All corresponding data from the client table in question, but there are two tasks for the same client, but only the first one appears.
– Wagner Viana