title: Using AJAX to require a specific php file
body: <p>I have 3 clickable menu items on my page:</p>
  
  <blockquote>
    <ul>
    <li>option1</li>
    <li>option2</li>
    <li>option3</li>
    </ul>
  </blockquote>
  
  <p>I also have 3 php files on my server:</p>
  
  <blockquote>
    <ul>
    <li>option1.php</li>
    <li>option2.php</li>
    <li>option3.php</li>
    </ul>
  </blockquote>
  
  <p>To keep things simple, let's say option1.php echoes the number 1, option2.php echoes the number 2, etc.</p>
  
  <p>To avoid the page refreshing, I want to use AJAX, so when a user clicks option1, option1.php file will display the number 1. I hope I have made myself clear.</p>
  
  <p>What is a good way to do this?</p>
  
  <p><strong>EDIT:</strong> I've reviewed my question again and have come up with a solution.
  In my php file that contains my menu items I added an update area div.</p>
  
  <pre><code>&lt;div id="update_area"&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>My external javascript file contains onclick events which call a function that sends the menu item number to be processed by my AJAX php file. This tests my</p>
  
  <pre><code>$_GET[sent_data]
  </code></pre>
  
  <p>and if (for example) it equals 1, then it uses</p>
  
  <pre><code>require "option1.php";
  </code></pre>
  
  <p>Now that the functionality is working I can independently edit my option?.php files.</p>
  
  <p>I've voted SomeKittens answer as the one that was most helpful.</p>