title: How to get php function ouptut on client side?
body: <p>I am trying to execute PHP function(server-side) on button click in html (client-side). I want to pass a parameter to PHP function as <strong>name</strong> &amp; in return I want output as <code>Hello name</code>.
  I tried, but it's not showing,</p>
  
  <p><strong>Server-side</strong><br>
  The PHP file name is "<strong>name.php</strong>" having function <code>greet()</code> with parameter <code>$name</code> is as follows:</p>
  
  <pre><code>&lt;?php
  function greet($name)
  {
     echo "hello $name";
  }
  ?&gt;
  </code></pre>
  
  <p><strong>Client-side</strong><br>
  The HTML file consists of a button "Click me" which should send the name <code>John</code> to PHP page, and the <code>greet()</code> function should execute and output should display at client side as "Hello John" is as follows:</p>
  
  <pre><code>&lt;html&gt;
  
  &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"&gt;&lt;/script&gt;
  &lt;script&gt;
  $(document).ready(function()
  {
    $("#button").click(function(){
      $.ajax({
        type: "POST",
        url: "name.php",
        data: { name: "John" }
      }).done(greet(data) 
      {
        alert( "Data Saved: " + data);
      }); 
   });
  });
  &lt;/script&gt;
  
  &lt;input type="button" id="button" value="Click me"&gt;
  
  &lt;/html&gt;
  </code></pre>
  
  <p>I have used Ajax method for calling PHP function if any other POST method can give output, then please let me know.<br>
  Can someone please help to how to get output from PHP function to client-side on button click.</p>