title: Call to a member function get_col() on a non-object jQuery Wordpress
body: <p>I have a number of php files in my WordPress plugin the main file I am having issues with has a class in it and I can call one method from it as my display page loads and that works fine but when I try and do it from a third file from my jQuery post I get the error sated in the title of my question. The error is said to be in the file with the class but I can't see an error. I have made sure that <code>global $wpdb</code> has been added to every function so and the first function works to get the track names but doesn't if I call it again through my last code as a test. Any help would be appreciated.</p>
  
  <p><strong>Class file</strong></p>
  
  <pre><code>&lt;?php
  class SelectList
  {
  public $tableName;
  public $driverTableName;
  public $classTableName;
  public $posTableName;
  public $trackTableName;
  
  public function __construct()
  {
      global $wpdb;
       $tableName = $wpdb-&gt;prefix . "raceresults";
       $driverTableName = $wpdb-&gt;prefix . "driverData";
       $classTableName = $wpdb-&gt;prefix . "classData";
       $posTableName = $wpdb-&gt;prefix . "posData";
       $trackTableName = $wpdb-&gt;prefix . "trackData";
  }
  
  public function ShowTrack()
  {
      global $wpdb;
      $category = '&lt;option value="0"&gt;choose...&lt;/option&gt;';
      $postids = $wpdb-&gt;get_col("SELECT trackName FROM wp_trackData;");
      foreach ($postids as $value) 
      {
          $category .= '&lt;option value="' . $value . '"&gt;' . $value . '&lt;/option&gt;' ;
      }
      return $category;
  }
  
  public function ShowDate($track)
  {
      global $wpdb;
      $type = '&lt;option value="0"&gt;choose...&lt;/option&gt;';
      $postids2 = $wpdb-&gt;get_col("SELECT DISTINCT raceDate FROM wp_raceresults WHERE trackName = '" . $track . "';");
      foreach ($postids2 as $value2) 
      {
          $type .= "&lt;option&gt;" . $value2 . "&lt;/option&gt;"; 
      }
      return $type;
  }
  }
  
  $opt = new SelectList();
  </code></pre>
  
  <p><strong>jQuery Code</strong></p>
  
  <pre><code>jQuery(document).ready(function()
  {
      jQuery("select#kDate").attr("disabled","disabled");
      jQuery("select#kTrack").change(function()
      {
          jQuery("select#kDate").attr("disabled","disabled");
          jQuery("select#kDate").html("&lt;option&gt;wait...&lt;/option&gt;");
          var id = jQuery("select#kTrack option:selected").attr('value');
  
          jQuery.post("&lt;?php echo plugins_url("/race-results/getResults.php"); ?&gt;", {id:id} , function(data)
          {
              jQuery("select#kDate").removeAttr("disabled");
              jQuery("select#kDate").html(data);
          })
          .success(function() { alert("success"); })
          .error(function(xhr, status, detail) { alert("error ("+status+") : " + detail); })
       });
    });
  </code></pre>
  
  <p><strong>Get Result</strong></p>
  
  <pre><code>&lt;?php
  include "popDrp.php";
  echo $opt-&gt;ShowDate($_POST[id]);
  ?&gt;
  </code></pre>