2
Have function
calling an ajax. As follows 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 on the stream, I have a select for that 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, presents me like this:
{"usuarioon":"1","status":"fa fa-circle-o text-red"}
{"usuarioon":"3","status":"fa fa-circle-o text-red"}
That means it returns me correctly, but the problem is: how to split it individually? I’ve tried with ParseJson
, but it didn’t work, I think it’s because I’m returning a array
, within a 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, so I bring the user code attached. I need to set like this:
$('#'+data.usuarioon). addClass(date.status);
Someone’s been there, you can help me ??
I think the title of the question should be more specific, no?
– Wallace Maxters
And what do you think the title @Wallacemaxters should look like? From what I see the title would be simply to identify my problem, so there is the content... Anything I can add to clear my doubt ?
– Brunno Sena
It’s right that the content is in the question, so that’s why you need a good title. Because other people who go through your problem will be able to search and find.
– Wallace Maxters
Bruno just as a suggestion, the title should summarize the problem as short as possible, so anyone who sees your question, already knows the problem, and will read your description for more details on how it helps you solve. Don’t take it personally, @Wallacemaxters' suggestion was to help you improve the visibility of the question on the site :)
– user28595