Is it possible to return more than one value from jQuery call?
<p>I have this code: messages.php</p>

<pre><code>if (count($row) &gt; 0)
{
    foreach ($row as $r)
    {
        //some code setting variables
        if ($opened_once &gt;= 1)
        {   

        }
        else
        {
            echo "&lt;tr&gt;";
            echo '&lt;td&gt;&lt;a class="red_link" href="'.ADDRESS.'view_message.php?id='.$r['id'].'" id= "subject_id" &gt;&lt;span id = "subject"&gt;'.$r['subject'].'&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;';
            echo '&lt;td id = "unique_code1"&gt;'.$uniqueCode1.'&lt;span class="pink_text" id = "unique_code2"&gt;'.$uniqueCode2.'&lt;/span&gt;&lt;span id = "unique_code3"&gt;'.$uniqueCode3.'&lt;/span&gt;&lt;/td&gt;';
            echo "&lt;/tr&gt;";
        }
    }
</code></pre>

<p>I need to update <code>$r['id']</code>, <code>$r['subject']</code>, <code>$uniqueCode1</code>, <code>$uniqueCode2</code>, <code>$uniqueCode</code></p>

<p>My jQuery code:</p>

<pre><code>&lt;script&gt;
    $(document).ready(function()
    {
        refresh();
    });

    function refresh()
    {      
        $.post('getMessageDetails.php', function (json) {
        $("#subject").html(json.subject);
        $("#subject_id").html(json.subject_id);
        $("#unique_code1").html(json.unique_code1);
        $("#unique_code2").html(json.unique_code2);
        $("#unique_code3").html(json.unique_code3);
        });   

        window.setTimeout(refresh,30000);
    }   
&lt;/script&gt;
</code></pre>

<p>Then I have newMessageCnt.php</p>

<pre><code>&lt;?php
&lt;?php
header('Content-Type: application/json; charset=utf-8');
include('header_application.php');

$limit = 15;
if(!isset($_GET['page']))
   $page = 1;
else
   $page = $_GET['page'];

$from = (($page * $limit) - $limit);
$row = $obj_clean-&gt;getMessages($_SESSION['user_id'], $from, $limit);

if (count($row) &gt; 0)
{
    foreach ($row as $r)
    {
        $codeLength = strlen($r['unique_code']);
        $codeLength = strlen($r['unique_code']);
        $firstPartLength = $codeLength - 5;
        $uniqueCode3 = substr($r['unique_code'], -2);
        $uniqueCode2 = substr($r['unique_code'], -5, 3);
        $uniqueCode1 = substr($r['unique_code'], 0, $firstPartLength);

        $message_id = $r['id'];
        $subject = $obj_clean-&gt;getMessageDetails($message_id);
        $opened_once = $obj_clean-&gt;getOpenedOnce($message_id);
        if ($opened_once &gt;= 1)
        {   
            $array['subject'] = $r['subject'];
            $array['subject_id'] = $r['id'];
            $array['unique_code1'] = $uniqueCode1;
            $array['unique_code2'] = $uniqueCode2;
            $array['unique_code3'] = $uniqueCode3;
        }
    }    
}
echo json_encode($array);
exit();
</code></pre>

<p>?>
    ?></p>

<p>I call this .php somewhere else as well where I just want the value of <code>echo $obj_clean-&gt;getUnopenedMessagesCount($_SESSION['user_id']);</code> </p>

<p>But from my messages.php I want </p>

<pre><code>echo '&lt;td&gt;&lt;a class="blue_link" href="'.ADDRESS.'view_message.php?id='.$r['id'].'"&gt;'.$r['subject'].'&lt;/a&gt;&lt;/td&gt;';
echo '&lt;td&gt;'.$uniqueCode1.'&lt;span class="pink_text"&gt;'.$uniqueCode2.'&lt;/span&gt;'.$uniqueCode3.'&lt;/td&gt;';
</code></pre>

<p>I'm not sure if I'm doing this right, some advice please?</p>
