title: calling a specific PHP function with AJAX
body: <p>Updated with page titles.</p>
  
  <p>This is on Leaderboard.php. you can see I've currently got the PHP call in the tbody. </p>
  
  <pre><code>  &lt;!-- The Leaderboard Table  --&gt;
      &lt;table id="tblData" class="table table-hover leaderboard-table target"&gt;
  
      &lt;thead&gt;
        &lt;tr&gt;
          &lt;th class="hidden-phone"&gt;Rank&lt;/th&gt;
          &lt;th&gt;Sales Person&lt;/th&gt;
          &lt;th&gt;Total Points&lt;/th&gt;
        &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody id="leaderboardresults"&gt;
        &lt;?php $getLeaderboard-&gt;getTable($_GET['competitionId']); ?&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
    &lt;!-- The Leaderboard Table END  --&gt;
  </code></pre>
  
  <p>This is on API/getLeaderboard.php. This is where the getTable function is.</p>
  
  <pre><code> &lt;?php
  class getLeaderboard {
    public function getTable($competitionId) {
  //I run the SQL query and echo out some PHP
      }
  </code></pre>
  
  <p>This is on Leaderboard.php. </p>
  
  <pre><code>   function loadLeaderboard() {
         var competitionId = $("body").attr("data-competitionId");
         var url = "api/getLeaderboard.php?competitionId=" + competitionId;
  
         $.get(url, function(data) {
              //$("#leaderboardresults").html(data);
         });
       }
  </code></pre>
  
  <p>This is also on Leaderboard.php. Another AJAX call that does a AJAX get (this works perfectly), and should reload the leaderboard on success.</p>
  
  <pre><code> $(function() {
        //this works (/James)
      $(".navVisible").click(function() {
          var Competition = $("body").attr("data-competitionId");
          var Activity = $(this).attr("data-activity");
          $.post("registerresults.php", { data: Activity, competitionId: Competition })
          .done(function(data) {
              loadLeaderboard();
          });
      });
      loadLeaderboard();
    });
  </code></pre>
  
  <p>This is getLeaderboardTable.php</p>
  
  <pre><code>    &lt;?php 
  include "common/common.php";
  include "api/getLeaderboard.php";
  $competitionId = $_GET['competitionId'];
  $getLeaderboard-&gt;getTable($competitionId); 
  ?&gt;
  </code></pre>