title: How to call only php function not whole page with ajax?
body: <p>I want to return data only from the php function not whole page data.
  Here is my demo.php file -</p>
  
  <pre><code>    &lt;?
      echo "Whole Page data";
  
      $name = $_POST['name'];
  
      if ($name == "demo"){
          demo();
      }
      else{
          echo "No";
      }
      function demo(){
         echo "demo data";
  }
  
  ?&gt;
  </code></pre>
  
  <p>And my ajax funtion is this -</p>
  
  <pre><code>function myAjax () {
          $.ajax( { type : 'POST',
                  url  : 'demo.php',
                  data : "name=demo",
                  success:function(data){
                         alert (data);
                 }
         });
  }
  </code></pre>
  
  <p>But it return whole page data with function data but I want only function data.</p>