Let's say I have the following table:
IhaveanoptionthatIclicktoactivatetheusersselectedbycheckboxes.Everythingalreadyworkingandevenoccurstheactivationofusers.I'musingAjaxbyhavingthebrowsercommunicatewiththeserverandactivatetheuserwithouthavingtoloadthewholepageagain.Myonlyquestionisthis:AftertheuserisactiveIwanttochangethecheckedcelloftheStatusfieldto:ActiveandColorGreen.Would?
IalreadydidsomethingwithaddClass('Ativo')
butIonlymanagedtoleaveallthewordsonthelineingreen.Iwouldlikeonlythecelltochangetoactiveandgreen.
FornowIhavethisinmycode:
$('i.icon-check').closest('li').click(fnAtivar);functionfnAtivar(){varparaAtivar=$('#tableUsuariotrinput:checkbox:checked').map(function(){return{cod_user:this.value,tr:$(this).closest('tr').get()}});$.ajax({url:"ativarUsuario.php",
type: 'post',
data: {
codigosAtivar: paraAtivar.map(function () {
return this.cod_user
}).get()
},
success: function (resposta) {
resposta = JSON.parse(resposta);
console.log(resposta, typeof resposta, typeof resposta[0], resposta[1]);
if (resposta[0]) paraAtivar.each(function(){
//aqui acredito que vai o código para realizar a alteração
});
alert(resposta[1]);
}
});
}