I've written a Wordpress wordpress plugin which creates content for any page, then attempts to call Update.php via jQuery.load to refresh the outcomes. For instance:

Wordpress plugin creates the information:

global $wpdb;
$sql = "SELECT * FROM table ORDER BY id;";
$results = $wpdb->get_results($sql);
<div id="content">Database Results Here Via Loop</div>

jQuery calls Update.php:

<script type="text/javascript">
$(function() {
  var refresh = setInterval(function() {
    $("#content").load("Update.php");
  }, 5000);
});

Update.php consists of:

<?php
function update_page() {
  global $wpdb;
  $sql = "SELECT * FROM table ORDER BY id;";
  $results = $wpdb->get_results($sql);
  echo "Parsed results go here";
}
update_page();
?>

After 5 seconds, this produces a 'Fatal error: Call to some member function get_results() on the non-object' around the primary page.

Basically just make Update.php return something similar to rand(), it works fine and updates the div having a random number. However, basically make an effort to range from the header that defines all of the Wordpress classes (i.e. $wpdb) within the Update.php file (e.g. require_once("wordpress-blog-header.php")) then your AJAX simply reduces altogether, and will not even return a rand(), yet it will avoid the fatal error pointed out above from occurring.

I'm completely lost. Any help or simply pointing me within the right direction could be greatly appreciated. Thanks ahead of time, kind sirs.

you're calling update.php file using ajax so wordpress is not able to load other its files so it's not finding $wpdb objects definition so you must do is require_when the wordpress-config.php and wordpress-includes/wordpress-db.php files

and make an item as $wpdb = new wpdb(DB_USER, DB_PASSWORD, DB_NAME, DB_HOST);

prior to the function update_page()