title: Loading Content using Ajax with PHP Include
body: <p>I have a PHP page which has a div, the div has a PHP includes which includes this file:</p>
  
  <pre><code>&lt;?php   
      include('mySql.php');
      include('Classes.php');
  
      $targetPage = "blogOutput.php";
      $noOfPosts = getNumberOfPosts();
      $adjacents = 3;
  ?&gt;
  &lt;link rel="stylesheet" type="text/css" href="Styles/Miniblog.css" /&gt;
  &lt;script src="Scripts/jQuery.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript"&gt;
      var page = 1;
      $(".Button").click(onClick());
      $(document).ready(onClick());
  
      function onClick() {
          alert('called');
          $("#posts").load("miniBlog.php", function(response, status, xhr) {
              if (status == "error") {
                  var msg = "Error!: ";
                  alert(msg);
              }
          });
          page++;
      }
  
  &lt;/script&gt;
  &lt;div class="PostTitle"&gt;
      &lt;h2&gt;What's New!?&lt;/h2&gt;
  &lt;/div&gt;
  &lt;div id="posts"&gt;
  &lt;/div&gt;
  &lt;a class="BlogButton" href=""&gt;Next&lt;/a&gt;
  </code></pre>
  
  <p>I need the function "onclick" to be called without refreshing the page and resetting the "page" variable in javascript. So far, all I've been able to do is make it run the script once. I think that's wrong too, because it's not loading any content. Here's the page:</p>
  
  <pre><code>&lt;?php
      echo "I'm here!";
      if (isset($_POST['offset'])) {
          $offset = $_POST['offset'];
  
          $posts = getPosts($offset);
      }
  ?&gt;
  
  &lt;div class="BlogPost"&gt;
      &lt;h3&gt;&lt;?php echo $posts[0]-&gt;Title; ?&gt;&lt;/h3&gt;
      &lt;p&gt;&lt;?php echo $posts[0]-&gt;Body; ?&gt;&lt;/p&gt;
      &lt;p class="Date"&gt;&lt;?php echo $posts[0]-&gt;Date; ?&gt;&lt;/p&gt;
  &lt;/div&gt;
  &lt;div id="divider"&gt;&lt;/div&gt;
  &lt;div class="BlogPost"&gt;
      &lt;h3&gt;&lt;?php echo $posts[1]-&gt;Title; ?&gt;&lt;/h3&gt;
      &lt;p&gt;&lt;?php echo $posts[1]-&gt;Body; ?&gt;&lt;/p&gt;
      &lt;p class="Date"&gt;&lt;?php echo $posts[1]-&gt;Date; ?&gt;&lt;/p&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>So, to clarify: I'm not sure why my ajax call isn't working, and I don't know how to load just the div content and not refresh the entire page. Thanks!</p>