I have the following ajax code:
$.ajax({
type: 'post',
url: '/conversation/test',
data: { conversation: JSON.stringify(<?php echo json_encode($conversation) ?>) },
success: function (response) {
console.log(response);
}
});
Now I have on my test.php:
<?php
$conversation = json_decode($_POST['conversation']);
?>
<?php foreach ($conversation->getUsers() as $conUser) {
// Skip current user
if ($conUser->getId() == UserSession::getUserId()) {
continue;
} ?>
<a href="/<?php echo $conUser->getUri(); ?>/"><?php echo $conUser->getName(); ?></a>
<?php } ?>
And my response on the console is:
<br />
<b>Fatal error</b>: Call to undefined method stdClass::getUsers() in <b>/Users/msalamanca/PhpStorm/pinporn/trunk/application/views/default/conversation/test.php</b> on line <b>8</b><br />
I don't understand what I am doing wrong here.