You will see I have three variables in my javascript function that is as follows:
function search_person_report(){
var User_persons = $("#email_person").val();
var names = $("#names").val();
var lastnames = $("#lastnames").val();
console.log(name);
$.ajax({
type: 'POST',
async: true,
cache: false,
url: person_report,
dataType: 'json',
data: {User_persons:User_persons,names:names,lastnames:lastnames},
success: function (data, textStatus, jqXHR) {
console.log(data);
var result_person = "";
$.each(data,function(i,item){
result_person +='<tr>';
result_person += '<td>'+item.usuario+'</td>';
result_person += '<td>'+item.Nombre+'</td>';
result_person += '<td>'+item.Apellidos+'</td>';
result_person += '<td>'+item.fecha_creacion+'</td>';
result_person += '<td><input type="checkbox" value="'+item.id_persona+'" name="id_person[]"></td>';
result_person +='</tr>'
});
$("#resultperson").html(result_person);
}
});
}
well there is no problem, the issue is that these variables I have validate them, that is, if they are empty or not within the function in cakephp and then pass it to the SP which will send me the data to show them, here the code cakephp
public function searchpersongroup() {
$IdUser = $this->Auth->user('id_usuario');
$user = $this->request->query('User_persons');
$names = $this->request->query('names');
$lastnames = $this->request->query('lastnames');
if (!empty($user)) {
$user = '%'.$user;
}else{
$user = null;
}
if (!empty($names)) {
$names = '%'.$names;
}else{
$names = null;
}
if (!empty($lastnames)) {
$lastnames = '%'.$lastnames;
}else{
$lastnames = null;
}
$connection = ConnectionManager::get('default');
$query_search = $connection->execute('CALL ser_search_persons_rpt_grupal(:_IdUser,:_User,:_Names,:_Lastnames)',[
':_IdUser'=> $IdUser,':_User'=> $user, ':_Names' => $names,':_Lastnames' => $lastnames])->fetchAll('assoc');
if ($this->request->is('ajax')) {
echo json_encode($query_search);
die();
}
}
When I do the test it shows me empty, I do not know what is wrong doing help please