Hello everybody,
I am trying to send data to javascript:
In the controller I have (I took out the sql):
$data = Entries::model()->findallbysql();
In the view I am calling a function with the data:
<script type="text/javascript">functionxy(<?php echo CJavaScript::jsonEncode($data); ?>)</script>
in the js function i am trying to alert the recieved data:
alert(data[0].comment);
results into undefined.
However using this directly in the view works:
<?php echo $data[0]->comment; ?>
But I need the data in javascript.
What am i doing wrong?
How am I supposed to send data to js correctly?
Any help is greatly appreciated