how to properly insert html with jquery
<p>I am using this bit of PHP to return a chunk of html:</p>

<pre><code>if ($action = "update")
    {

        connect_db();

        $query = mysql_query("SELECT * FROM convo ORDER BY date ASC") or die (mysql_error());

        while($row = mysql_fetch_array($query))
        {
            $output = $output . '&lt;p&gt;';
            $output = $output . '&lt;b&gt;From:&lt;/b&gt; ' .$row['from'];
            $output = $output . ' &lt;b&gt;To:&lt;/b&gt; ' .$row['to'];
            $output = $output . ' &lt;b&gt;Message:&lt;/b&gt; ' .$row['content'];
            $output = $output . "&lt;br /&gt;";
            $output = $output . '&lt;/p&gt;';
        }

        //htmlentities($output);

        header('Content-Type: application/json');
        echo json_encode( $output );
    }
</code></pre>

<p>And then insert it into a <code>&lt;div&gt;</code> with this bit of jQuery:</p>

<pre><code>function update(){

        $.ajax({
            type: "GET",
            url: "actions.php",
            data: {  
                'action': 'update'
                },
            dataType: "json",
            success: function(data)
            {
                console.log('update called');
                console.log( data);
                $('#history').text( data );

                //$('#status').text('sent!');
            }
        });             

        setTimeout(update, 5000);
    }   
</code></pre>

<p>The ajax call works and returns the correct html however when inserted it is not formatted, I can see all the html code in the browser. See example picture: <img src="http://i.stack.imgur.com/nU1Kz.png" alt="browersoutput"></p>

<p>Should be using something other than <code>.text</code>?</p>
