title: Using jQuery's .get() to retrieve PHP data
body: <p>I'm using jQuery's .ajax() to post to a PHP file called process.php. Process.php has a lot of code in it, but for simplicity's sake, let's just say it contains <code>&lt;?php echo 'hello'; ?&gt;</code>.</p>
  
  <p>Is this the proper jQuery to insert process.php's results into <code>div.results</code>? :</p>
  
  <pre><code>$.get('process.php', function(data) {
      $('.results').html(data);
  });
  </code></pre>
  
  <p>So far it doesn't seem to be working.</p>
  
  <p>Here's the HTML/Javascript file</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  
  &lt;html lang="en"&gt;
  
  &lt;head&gt;
      &lt;meta charset="UTF-8" /&gt;
      &lt;script type="text/javascript" src="http://code.jquery.com/jquery-1.5.js"&gt;&lt;/script&gt;
      &lt;script type="text/javascript"&gt;
          $(document).ready(function() {
              $("form#form").submit(function() {
                  var username = $('#username').attr('value');
                  $.ajax({
                      type: 'POST',
                      url: 'process.php',
                      data: 'username=' + username,
                      success: function() {
                          $('form#form').hide(function() {
                              $.get('process.php', function(data) {
                                  $('.results').html(data);
                              });
                          });
                      }
                  });
                  return false;
              });
          });
      &lt;/script&gt;
  
  &lt;/head&gt;
  
  &lt;body id="body"&gt;
  
  &lt;form id="form" method="post"&gt;
      &lt;p&gt;Your username: &lt;input type="text" value="" name="username" id="username" /&gt;&lt;/p&gt;
      &lt;input type="submit" id="submit" value="Submit" /&gt;
  &lt;/form&gt;
  
  &lt;div class="results"&gt;&lt;/div&gt;
  
  &lt;/body&gt;
  
  &lt;/html&gt;
  </code></pre>
  
  <p>Here's <code>process.php</code> (greatly simplified): </p>
  
  <pre><code>&lt;?php
      /* get info from ajax post */
      $username = htmlspecialchars(trim($_POST['username']));
      echo $username;
  ?&gt;
  </code></pre>