title: Make ajax call to a php function include on same page
body: <p>My question might sound old and already answered to you but I did not find a satisfying answer to my question. Let me explain my scenario clearly,</p>
  
  <p>I got index.php like this</p>
  
  <p><strong>index.php</strong></p>
  
  <pre><code>&lt;?php   
      inlcude("connect.php");   
      include("functions.php");   
  ?&gt;
  
  &lt;html&gt;   
      $(document).ready(function() {    
          $('#button').click(function() {    
              $.ajax({    
                  type: 'GET',    
                  data: 'method=test',    
                  success: function(data) {    
                      alert(data);    
                  }
              });    
          });    
      });
  &lt;/html&gt;
  </code></pre>
  
  <p>I did not pass the URL in the ajax call and I got the data alert successfully but the entire page from <code>&lt;html&gt;</code> to <code>&lt;/html&gt;</code>. When I provide the url to functions.php I get the expected output in the alert box. </p>
  
  <p>I hope you guyz have a close guess about my question. My question is I need to call a function from <code>functions.php</code> which is already included in my <code>index.php</code> page. I don't wanna use <code>functions.php</code> again in the ajax 'URL: ' as <code>functions.php</code> would be called twice. This is to avoid server load.</p>
  
  <p>Let me the you guyz come up with interesting ideas.</p>
  
  <p>Thank you.</p>