title: How can I pass a value from jQuery to PHP
body: <p>I have a simple button when I click it I wish to pass a value from jQuery and send it to a PHP file so I can execute it. So when the button is clicked the onclick event is triggered, it sends the number "1" to the jQuery code and in turn jQuery should send "1" to the PHP function displayRecords, and "1" should be echoed :). If you can help, it would be greatly appreciated.</p>
  
  <p><strong>HTML</strong></p>
  
  <pre><code>&lt;input type="button" value = "Click Me!" 
      id = "btn" nam = "btn" onClick="displayRecord(1)"&gt;
  </code></pre>
  
  <p><strong>jQuery</strong> </p>
  
  <pre><code>&lt;script&gt;
      function displayRecord(num) {
          $.ajax({
              type: 'post',
              url: "display.php",
              data: { num: num }
          });
      };
  &lt;/script&gt;
  </code></pre>
  
  <p><strong>PHP</strong></p>
  
  <pre><code>&lt;?php
      function displayRecord($num) {
          echo $num;
      }
  ?&gt;
  </code></pre>