I have the following data that is returned in json to recover the ones with jquery
$response = array($query_license,$query_estate);
if ($this->request->is('ajax')) {
echo json_encode($response,TRUE);
die();
}
this is the answer of the json in php code
[[{"cantidad_pendiente":5}],[{"estado":3}]]
my function to recover the json data
$.ajax({
type: 'GET',
async: true,
cache: false,
url: license,
dataType: 'json',
data:{id_user_license:id_user_license,id_evaluation:id_evaluation},
success: function (data){
$.each(data,function(i,s){
console.log(s);
if(s[0].cantidad_pendiente === 0){
$("#message_license").html('<p>Usted no cuenta con licensias disponibles</p>');
$("#modal_report__footer").html('<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancelar</button>');
}else if(s[0].estado === 3){
$("#message_license").html('<p>Usted cuenta con '+ s[0].cantidad_pendiente +'</p>');
$("#message_consumed").html('<p>Esta evaluacion ya consumio licencia</p>');
$("#modal_report__footer").html('<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancelar</button>');
}else{
$("#message_license").html('<p>Usted cuenta con '+ s[0].cantidad_pendiente +'</p>');
$("#modal_report__footer").html('<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancelar</button> <button type="submit" class="btn btn-danger">Consumir</button>');
}
});
}
});
now verify the data with console.log(data);
this was the result
Now when I do the same but within each
$.each(data,function(i,s){
console.log(s)
}
I find this
Now my question is how I position myself in quantity_and show its value to the user, because doing so $("#message_license").html('<p>Usted cuenta con '+ s[0].cantidad_pendiente +'</p>');
within my if it shows me undefined maybe I'm doing wrong: (