title: Link PHP with JQuery after clicking a button
body: <p>I'm trying to process some PHP after a button is clicked with Jquery's AJAX function. The problem is that I can't link the JQuery's AJAX function with my PHP. There is no data to be send, I just want to procces some PHP code after clicking it. I tried adding a dummy data field in the AJAX code called 'btnpressed', but it didn't work.</p>
  
  <p>I tried to find a solution, but, most sites just stick with form/data processing.</p>
  
  <p>PS: note that the PHP code is on the same page as the HTML and Javascript.</p>
  
  <p><strong>HTML:</strong></p>
  
  <pre><code>&lt;button id='btn'&gt;Do something&lt;/button&gt;
  </code></pre>
  
  <p><strong>Javascript/JQuery:</strong></p>
  
  <pre><code>&lt;script&gt;
  $(document).ready(function() {
     $("#btn").click(function() {
      $.ajax({
          type:"POST",
          url: "samepage.php"}
          });
      });
  
  });
  &lt;/script&gt;
  </code></pre>
  
  <p><strong>PHP:</strong></p>
  
  <pre><code>if(isset($_POST['btnpressed'])){
  //Do some database stuff
  }
  </code></pre>