For example:
You have to make the page that ajax calls a template page. Make a new page in your blog and assign the template. no headers no includes.
You have to include the file that has the Wordpress functions located on the main directory of the Wordpress Installation:
define('WP_USE_THEMES', false);
require_once('../../../wp-load.php');
../../../ = path to the main directory on your installation
I found a nice tutorial about this here.
This worked for me, maybe it will help someone else.
My situation is I have a js file that uses getScript. In that script i have a bunch of .load() calls to a php file. At the top I place this.
if (file_exists("../../../wp-load.php"))
{
require_once("../../../wp-load.php");
}
Change the ../
to how ever many directories your wp-load file is up.
Edit - Using WP 3.4.1
You can turn the template engine off and then include the header.
// Include WordPress
define('WP_USE_THEMES', false);
require_once('PATHHERE/wp-blog-header.php');