title: Returning HTML (with PHP) after jQuery Ajax function
body: <p>I'm trying to use Ajax together with jQuery to make a little window pop up when you click on a username in my custom forums.</p>
  
  <p>My current code for the script:</p>
  
  <pre><code>$(document).ready(function () {
      $('#profile_link').click(function () {
  
          $.ajax({
              type: 'POST',
              url: 'viewuser.php',
              dataType: 'html',
              contentType: 'text/html',
              data: {
                  username: $('#username').val()
              },
              success: function (html) {
                  $('#message').addClass('success');
                  $('#message').hide().append(html).fadeIn();
              }
          });
  
          return false;
      });
  });
  </code></pre>
  
  <p>I tried using html(), but that didn't work at all, as it didn't even display the response, even though I could see the response in Firebug.</p>
  
  <p>Here's the code to viewuser.php:</p>
  
  <pre><code>        &lt;?php 
        $docRoot = getenv("DOCUMENT_ROOT");
  
        require_once $docRoot.'/settings.php';
  
        loginMySQL();
  
        selectDatabase();
  
        $user = $_POST['username'];
  
        $sql = mysql_query ("SELECT `UserName`,`Avatar`,`Biography`,`Birthday`,`UserLevel`,`BanStatus` FROM users WHERE `UserName` = '$user'");
  
        $UserInfo = mysql_fetch_array($sql);
         $UserAvatar = $UserInfo['Avatar'];
         $UserBio = $UserInfo['Biography'];
         $UserBirth = $UserInfo['Birthday'];
         $UserLevel = $UserInfo['UserLevel'];
         $BanStatus = $UserInfo['BanStatus'];
  
     // additional code
     ...
        ?&gt;
        &lt;div class="nav_space"&gt;
        &lt;/div&gt;
  // additional code
        &lt;div class="user_profile_wrapper"&gt;
         Hello
         &lt;?=$BanStatus;?&gt;
         &lt;i&gt;Username / Power level:&lt;/i&gt;
         &lt;div class="user_profile_name" &lt;?=$LevelColour;?&gt;&gt;
         &lt;?=$user;?&gt; &lt;i&gt;&lt;?=$UserLevel;?&gt;&lt;/i&gt;
         &lt;/div&gt;
         &lt;i&gt;User avatar:&lt;/i&gt;
         &lt;div class="user_profile_avatar"&gt;
        &lt;?
         if (strlen($UserAvatar) &gt; 1) {
         ?&gt;
         &lt;img/ src="&lt;?=$UserAvatar;?&gt;" alt="" width="100" /&gt;
         &lt;?
         }
        ?&gt;
         &lt;/div&gt;
         &lt;i&gt;Biography:&lt;/i&gt;&lt;br /&gt;
         &lt;div class="user_profile_bio"&gt;
         &lt;?=$UserBio;?&gt;
         &lt;/div&gt;
         &lt;i&gt;Birthdate:&lt;/i&gt;
         &lt;div class="user_profile_birthdate"&gt;
         &lt;?=$UserBirth;?&gt;
         &lt;/div&gt;
         &lt;?=$AUserLevel;?&gt;
        &lt;/div&gt;
        &lt;div class="nav_space"&gt;
        &lt;/div&gt;
  </code></pre>
  
  <p>And the problem is, when it returns the code, it doesn't actually display any of the variables ($BanStatus, $UserLevel, anything). </p>
  
  <p>Any ideas?</p>