I have this code:
<script> $(document).ready(function() { refresh(); }); function refresh() { $.get('getMessageDetails.php', function (json) { alert(json); alert(json[0].subject); },"json"); window.setTimeout(refresh,30000); } </script>
then I have getMessageDetails.php:
<?php //header('Content-Type: application/json; charset=utf-8'); include('header_application.php'); $lastNewMessageCnt = $obj_clean->getUnopenedMessagesCount($_SESSION['user_id']) + 1; $last_unopened_message_row = $obj_clean->getLastUnopenedMessage($_SESSION['user_id'],$lastNewMessageCnt); echo json_encode($last_unopened_message_row); ?>
then I have a warning (json) that shows:
[{"subject":"Freechat ddd","id":"19","created_at":"2011-08-29 14:58:27","unique_code":"ALLEYCA000RC","opened_once":"0"}]
what is true
but alert(json[0].subject); gives undefined
please, help? thanks
source share