I try to make a system that keeps track of certain statistics for a user like, the number of new messages etc.
This is what I have sofar:
HTML
<li><a href="#" class="">Berichten <span class="badge credits"><?= $credits ?></span></a></li>
<li><a href="#" class="">Berichten <span class="badge nw_berichten"><?= $nw_berichten ?></span></a></li>
Javascript
function profielAantallen(){
$.ajax({
type: "POST",
url: "/profielen/aantallen",
dataType: 'json',
async: true,
cache: false,
timeout:50000,
success: function(data){
if ( data ) {
$(".credits").html(data.credits);
$(".nw_berichten").html(data.nw_berichten);
}
setTimeout(profielAantallen, 10000);
}
});
};
profielAantallen();
url: “/profielen/aantallen”
public function aantallenAction()
{
$profiel = $this->session->get('profiel');
$aantallen = $this->aantallen->get_profiel_aantallen($profiel);
echo json_encode(array(
'credits' => $credits,
'nw_berichten' => $nw_berichten
));
}
I thought this would do the trick but I get an error that both values are undefined. Does anyone see what i am doing wrong? Thank you in advance