I have an array in a php variable called $result.
When I do echo json_encode($result); I get:
[{"id":"4","rank":"adm","title":"title 1"},
{"id":"2","rank":"mod",,"title":"title 2"},
{"id":"5","rank":"das","title":"title 3"},
{"id":"1","rank":"usr""title":"title 4"},
{"id":"3","rank":"ref","title":"title 5"}]
However I get a different result when try to get same using alert. Here is the example.
<script type="text/javascript">
//<![CDATA[
$(document).ready(function() { myArray = <?=json_encode($result);?>; });
$('img.delete').click(function() { alert(myArray); }
//]]>
</script>
The alert that I get is [object Object],[object Object], ...
I am not sure, but it seems that the variable myArray is not properly getting carried to $('img.delete').click(function().