I\'m posting some data to a PHP script via jQuery AJAX, and everything executes correctly, but it returns a 404 error. In my Firebug console the response from the PHP scrip
No one else posted this as an answer, so it's worth noting. You should be including wp-load.php
instead of wp-blog-header.php
.
If you open up wp-blog-header.php
you'll see why:
if ( !isset($wp_did_header) ) {
$wp_did_header = true;
require_once( dirname(__FILE__) . '/wp-load.php' );
wp();
require_once( ABSPATH . WPINC . '/template-loader.php' );
}
If you are only outputting json for an AJAX operation, you do not need to include template-loader.php
. This will create unnecessary overhead, and then of course provide the 404 error.
This 'workaround' is necessary for current and future versions of WordPress. I'm assuming anything past 3.0 should include wp-load.php
as stated.