I have a very simple script like so:
$(function() {
var url = theme_directory + '/func/api.php';
$.get( url, function(data) {
alert("Data Loaded: " + data);
});
});
And the api.php looks like this:
<?php
echo('hello');
define('WP_USE_THEMES', false);
require_once( dirname( __FILE__ ) . '/../../../../wp-blog-header.php' );
This works. However when I put the exit below like so:
<?php
define('WP_USE_THEMES', false);
require_once( dirname( __FILE__ ) . '/../../../../wp-blog-header.php' );
echo('hello');
And I browse to the api.php it shows me 'hello' however when I use the javascript it doesn't show me the alert. Moving the hello back up, it works again. It gets me so confusedddd.
<?php
echo ' ';
define('WP_USE_THEMES', false);
require_once( dirname( __FILE__ ) . '/../../../../wp-blog-header.php' );
print_r($wp);
Now javascript will show me the contents of $wp... however, removing the echo ' ';
and the javascript alert will not be triggered.
It has something to do with the WordPress Permalinks. When I turn it off, it works, when I turn it on it does not.