Jquery html() isn't working, but text() does
<p>Hey, I'm having a strange issue with jquery's ajax events, and html(). I'm building a calendar/event thing for something, and everything works except for the html() bit.
This is the code, (Sorry, kinda long)</p>

<p>Jquery:</p>

<pre><code>$(function() {
 var months = new Array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');
 var days = new Array('S', 'M', 'T', 'W', 'T', 'F', 'S');
 var date = new Date();

$('#next').click(function() {       
    //gets current year from page
    var curMon = $('#month').text();
    for(var i in months) {
        if(months[i] == curMon) {
            //if not dec, increment i
            if(i != 11) {
                i++;
            } else {
            //else, back to jan and increment year
                i = 0;
                var curYear = $('#year').text();
                curYear = parseInt(curYear) + 1;
                curYear = curYear.toString();
                $('#year').text(curYear);
            }
            $('#month').html(months[i]);
            var yy = parseInt( $('#year').text() );
            var days = daysInMonth(i, yy);
            //clear all the dates
            $('.day').each(function() {
                $(this).text('');
            });
            $.ajax({
               type: "POST",
               url: "some.php",
               data: "month="+months[i],
               success: function(msg){
                 $('#month_fields').html(msg);
               }
             });                
            var firstDay = new Date(months[i]+', 1 ' + yy);
            firstDay = firstDay.getDay();
            var j = 1;
            while(j &lt;= days) {
                //fills in dates starting in the correct spot
                $('.day').eq(firstDay).text(j);
                firstDay++;
                j++;
            }

        }

    }
});

$('#prev').click(function() {
    var curMon = $('#month').text();
    for(var i in months) {
        if(months[i] == curMon) {
            if(i != 0) {
                i--;
            } else {
                i = 11;
                var curYear = $('#year').text();
                curYear = parseInt(curYear) - 1;
                curYear = curYear.toString();
                $('#year').text(curYear);
            }
            $('#month').html(months[i]);
            var yy = parseInt( $('#year').text() );
            var days = daysInMonth(i, yy);
            $('.day').each(function() {
                $(this).text('');
            });
            $.ajax({
               type: "POST",
               url: "some.php",
               data: "month="+months[i],
               success: function(msg){
                 $('#month_fields').html(msg);
               }
             });                
            var firstDay = new Date(months[i]+', 1 ' + yy);
            firstDay = firstDay.getDay();
            var j = 1;
            while(j &lt;= days) {
                $('.day').eq(firstDay).text(j);
                firstDay++;
                j++;
            }
        }
    }
});});
</code></pre>

<p>some.php:</p>

<pre><code>    &lt;?php
ob_start();     
    $cal_months = array(
    "January" =&gt; "01",
    "February" =&gt; "02",
    "March" =&gt; "03",
    "April" =&gt; "04",
    "May" =&gt; "05",
    "June" =&gt;"06",
    "July" =&gt; "07",
    "August" =&gt; "08",
    "September" =&gt; "09",
    "October" =&gt; "10",
    "November" =&gt; "11",
    "December" =&gt; "12",
    );
    $fs = $_POST['month'];
    $thismonth = ( int ) $cal_months[$fs];
    $thisyear = date( "Y" );
    $numdaysinmonth = cal_days_in_month( CAL_GREGORIAN, $thismonth, $thisyear );
    $jd = cal_to_jd( CAL_GREGORIAN, $cal_months[$fs],date( 1 ), date( "Y" ) );
    $startday = jddayofweek( $jd , 0 );
    $monthname = jdmonthname( $jd, 1 );

$emptycells = 0;
for( $counter = 0; $counter &lt;  $startday; $counter ++ ) {
    echo "\t\t&lt;td class='padding'&gt;&lt;/td&gt;\n";
    $emptycells ++;
}
$rowcounter = $emptycells;
$numinrow = 7;

for( $counter = 1; $counter &lt;= $numdaysinmonth; $counter ++ ) {
    $rowcounter ++;

    if($counter == $thisday){
        echo "\t\t&lt;td class='today'&gt;$counter&lt;/td&gt;\n"; // add class for today
    } else {
        echo "\t\t&lt;td class='cal_nums'&gt;$counter&lt;/td&gt;\n";
    }

    if( $rowcounter % $numinrow == 0 ) {
        echo "\t&lt;/tr&gt;\n";
        if( $counter &lt; $numdaysinmonth ) {
            echo "\t&lt;tr&gt;\n";
        }
        $rowcounter = 0;
    }
}
$numcellsleft = ($numinrow - $rowcounter);
if( $numcellsleft != $numinrow ) {
    for( $counter = 0; $counter &lt; $numcellsleft; $counter ++ ) {
        echo "\t\t&lt;td class='padding'&gt;&lt;/td&gt;\n";
        $emptycells ++;
    }
}   
$raw = ob_get_contents();
$eventarray[] = array(          
"month" =&gt; 5,           
"day" =&gt; 1,             
"title" =&gt; "April Fools",               
"desc" =&gt; "Have fun with those practical jokes!"                
);                      
$eventarray[] = array(          
"month" =&gt; 6,           
"day" =&gt; 4,             
"title" =&gt; "Easter",            
"desc" =&gt; "Easter Sunday"               
);                      
$eventarray[] = array(          
"month" =&gt; 7,           
"day" =&gt; 22,            
"title" =&gt; "Earth Day",                 
"desc" =&gt; "Protect the environment - Remember to keep the river and parks clean"                
);                      
$eventarray[] = array(          
"month" =&gt; 8,           
"day" =&gt; 9,             
"title" =&gt; "Mother's Day",              
"desc" =&gt; ""            
);                      
$eventarray[] = array(          
"month" =&gt; 9,           
"day" =&gt; 30,            
"title" =&gt; "Memorial Day",              
"desc" =&gt; ""            
);
foreach($eventarray as $value){
    if($value['month'] == $cal_months[$fs]){
        $raw = str_replace("&lt;td class='cal_nums'&gt;".$value['day']."&lt;/td&gt;","&lt;td class='date_has_event'&gt;".$value['day']."\r\n\t\t&lt;div class='events_info'&gt;\r\n\t\t&lt;ul&gt;&lt;li&gt;&lt;span class='title'&gt;".$value['title']."&lt;/span&gt;&lt;span class='desc'&gt;".$value['desc']."&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;\r\n\t\t&lt;/div&gt;\r\n\t\t&lt;/td&gt;",$raw);
    }
}
ob_clean();
echo $raw;
?&gt;
</code></pre>

<p>So, when I have the ajax responce set as .html(msg) it gives me only the last part of the calendar month:</p>

<pre><code>   &lt;div id="month_fields"&gt;
    &lt;td class="cal_nums"&gt;29&lt;/td&gt;
    &lt;td class="cal_nums"&gt;30&lt;/td&gt;
    &lt;td class="cal_nums"&gt;31&lt;/td&gt;
    &lt;td class="padding"&gt;&lt;/td&gt;
    &lt;td class="padding"&gt;&lt;/td&gt;
    &lt;td class="padding"&gt;&lt;/td&gt;
    &lt;td class="padding"&gt;&lt;/td&gt;
   &lt;/div&gt;
</code></pre>

<p>But when I have it set as .text(msg), I get the entire contents of $raw:</p>

<pre><code>&lt;td class='date_has_event'&gt;1 &lt;div class='events_info'&gt; &lt;ul&gt;&lt;li&gt;&lt;span class='title'&gt;April Fools&lt;/span&gt;&lt;span class='desc'&gt;Have fun with those practical jokes!&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt; &lt;/div&gt; &lt;/td&gt; &lt;td class='cal_nums'&gt;2&lt;/td&gt; &lt;td class='cal_nums'&gt;3&lt;/td&gt; &lt;td class='cal_nums'&gt;4&lt;/td&gt; &lt;td class='cal_nums'&gt;5&lt;/td&gt; &lt;td class='cal_nums'&gt;6&lt;/td&gt; &lt;td class='cal_nums'&gt;7&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td class='cal_nums'&gt;8&lt;/td&gt; &lt;td class='cal_nums'&gt;9&lt;/td&gt; &lt;td class='cal_nums'&gt;10&lt;/td&gt; &lt;td class='cal_nums'&gt;11&lt;/td&gt; &lt;td class='cal_nums'&gt;12&lt;/td&gt; &lt;td class='cal_nums'&gt;13&lt;/td&gt; &lt;td class='cal_nums'&gt;14&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td class='cal_nums'&gt;15&lt;/td&gt; &lt;td class='cal_nums'&gt;16&lt;/td&gt; &lt;td class='cal_nums'&gt;17&lt;/td&gt; &lt;td class='cal_nums'&gt;18&lt;/td&gt; &lt;td class='cal_nums'&gt;19&lt;/td&gt; &lt;td class='cal_nums'&gt;20&lt;/td&gt; &lt;td class='cal_nums'&gt;21&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td class='cal_nums'&gt;22&lt;/td&gt; &lt;td class='cal_nums'&gt;23&lt;/td&gt; &lt;td class='cal_nums'&gt;24&lt;/td&gt; &lt;td class='cal_nums'&gt;25&lt;/td&gt; &lt;td class='cal_nums'&gt;26&lt;/td&gt; &lt;td class='cal_nums'&gt;27&lt;/td&gt; &lt;td class='cal_nums'&gt;28&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td class='cal_nums'&gt;29&lt;/td&gt; &lt;td class='cal_nums'&gt;30&lt;/td&gt; &lt;td class='cal_nums'&gt;31&lt;/td&gt; &lt;td class='padding'&gt;&lt;/td&gt; &lt;td class='padding'&gt;&lt;/td&gt; &lt;td class='padding'&gt;&lt;/td&gt; &lt;td class='padding'&gt;&lt;/td&gt; 
</code></pre>

<p>I'm thinking it has something to do with the php file, but why would html vs. text output different things?</p>
