title: How to dynamically load a PHP page inside another PHP page's <DIV>?
body: <p>I currently have two PHP pages: test1.php and test2.php. Inside test1 are 2 DIVs: one named "SubmitDiv", and one named "DisplayDiv". Inside SubmitDiv is a Submit button. When the user clicks on the Submit button, it should load test2.php inside DisplayDiv. Currently test2.php will only display "Hello World". I want it to load test2.php inside the DisplayDiv so that the test1.php page doesn't need to break stride or otherwise reload.</p>
  
  <p>And this is where I am stuck. I am aware that I likely have to make use of AJAX in order for it to dynamically load the test2.php page inside DisplayDiv. How this is done, however, has bested me, and my attempts at it have so far failed. Using the below scripts, which I have pieced together from online searches of this issue, when I try to click on the Submit button - which should load test2.php inside DisplayDiv - instead it just refreshes the whole page and no test2.php is loaded.</p>
  
  <p>test1.php:</p>
  
  <pre><code>&lt;html&gt;
  &lt;script src="http://code.jquery.com/jquery-1.9.1.min.js"&gt;&lt;/script&gt;
  &lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript"&gt;
      function loadSubmitResults() {
          $(function() {
              $('#DisplayDiv').load('test2.php');
          });
      }
  &lt;/script&gt;
  &lt;body&gt;
      &lt;div id="page"&gt;
          &lt;form id="SubmitForm" method="post"&gt;
              &lt;div id="SubmitDiv" style="background-color:black;"&gt;
                  &lt;button type="submit" form="SubmitForm" onclick="loadSubmitResults();"&gt;Submit&lt;/button&gt;
              &lt;/div&gt;
          &lt;/form&gt;
          &lt;div id="DisplayDiv" style="background-color:red;"&gt;
              &lt;!-- This is where test2.php should be inserted --&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p>test2.php:</p>
  
  <pre><code>&lt;html&gt;
  &lt;meta charset="utf-8"&gt;
  &lt;body&gt;
      &lt;div id="page" style="background-color:yellow;"&gt;
          &lt;?php
              echo "Hello World.";
          ?&gt;
      &lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>