I have function
calling an ajax. As below:
function verifica(){
var meuid = $('.meuid').attr('id');
var datas = "user="+meuid;
$.ajax({
type: "GET",
url: 'sys/stream2.php',
data: datas
}).done(function( data ) {
//alert(data);
$('#nome').html(data);
});
}
And in the stream, I have a select for it along with a foreach
as follows:
foreach ($gUsuarios as $usuarios) {
$agora = $usuarios['AGORA'];
if ($agora >= $usuarios['cUsu_Limite']) {
echo json_encode(array('usuarioon' => $usuarios['cUsu_ID'],
'status' => 'fa fa-circle-o text-red'));
}else{
echo json_encode(array('usuarioon' => $usuarios['cUsu_ID'],
'status' => 'fa fa-circle-o text-green'));
}
and the return, it presents me like this:
{"usuarioon":"1","status":"fa fa-circle-o text-red"}
{"usuarioon":"3","status":"fa fa-circle-o text-red"}
That means that it returns me correctly, but the problem is: how do you split this individually? I've tried with ParseJson
, but it did not work, I think it's because I'm returning array
, within foreach
.
What I really want is:
In the element it changes the class to: 'fa fa-circle-o text-green', but for this I need to know which user, then I bring the user's code. I need to look like this:
$ ('#' + data.user) .addClass (data.status);
Someone has already gone through this, can you help me?