Question

On my development machine everything works fine. On the live server (Godaddy), the AJAX requests from BuddyPress are returning results and a 404 error in FireBug. But the script is seeing the results as a fail and the indicators continue to spin.

Example: http://jobaru.com/ on the homepage there is Newest | Active | Popular under memebers using the AJAX as well as the letters on the groups page.

Things I have tried: Double checked the file was actually there first, checked permissions to be able to read. Did a fresh install.

Any ideas on why it would return 404 header and valid response?

Was it helpful?

Solution

I don't know why it returns 404, but try adding this line of code to /wp-content/plugins/buddypress/bp-core/bp-core-ajax-handler.php before do_action()

status_header( 200 );

I'm running a heavily modified version of BuddyPress 1.0 RC1, and intercept the ajax posts in bp-custom.php, but setting the status header in the custom file before I did my own logic worked just fine for me.

OTHER TIPS

Instead of hacking Buddypress core wich will brake on the next update you should add a function to intercept the requested action:

My problem was that inside a custom groups url in the activity loop, the "more link" was getting a 404 responde header error on admin-ajax.php. If i check the response content all the activity data was there. So im not sure what is causing the problem.

To solve it i added a function that will return a status header of 200 when the ajax call is triggered. In my case i needed for "get_older_updates" action but i suppose you can use it for any other action defined at /bp-themes/bp-default/_inc/ajax.php:27

add_action( 'wp_ajax_activity_get_older_updates', 'bp_dtheme_activity_template_loader2' );
add_action( 'wp_ajax_nopriv_activity_get_older_updates', 'bp_dtheme_activity_template_loader2' );

function bp_dtheme_activity_template_loader2(){
    if(isset($_REQUEST['action']) && $_REQUEST['action'] == 'activity_get_older_updates')
    {
        status_header( 200 );
    }
}   

This seems like it's something with GoDaddy, judging by your comments. Until you hear back from their support, I'd modify the AJAX script to ignore the 404 error for that particular request.

I was having this problem on GoDaddy and it was driving me crazy, but I found a solution. Sending a 200 status code (header("HTTP/1.1 200 OK");) didn't get rid of the 404 for me. I had a mod_rewrite rule that routed a standard URL into my index.php, so a URL like this:

www.example.com/myroute/ajax_get_current

Was being sent routed to my application essentially like this:

www.example.com/index.php/myroute/ajax_get_current

Pretty standard stuff. The problem was caused when I created a file at the document root with the same name as my route:

DOCROOT/myroute.php

Then I would get a result exactly as described -- a 404 error, but a proper response. I confirmed that if I changed the file to "myroute_cron.php" the 404 would disappear (a proper 200) and if I changed it back, it would give the 404.

I have no idea why this happens (especially since it was clearly executing the proper script to get the proper response), maybe something with MultiViews. Hope this helps.

I'm taking a look at the AJAX response, and it looks like instead of pure HTML that it's returning, it has this at the beginning: 0[[SPLIT]] and a zero at the end. Could this have something to do with it?

make sure you already added the error handler for the ajax fail (error)? try to hide the spin indicator first to see the effect taking place.

FWIW, I have seen the exact same problem with JSON-formatted replies as part of a WordPress plugin when hosted at GoDaddy.com. The JSON results are sent correctly, but the HTTP response has a status code of 404.

I am fairly convinced that this is a problem with their Apache header/configurations, and I will be trying to get a hold of their tech support team (wish me luck) in an attempt to get to the bottom of this.

I will post here if I get a response back from them.

I was getting the 404 response error while playing with Country city dropdown menu using AJAX and the problem was

<select name="lm_country" id="lm_coutry" 
    onChange="getCity('getcities.php?country='+this.value)">

Then I gave a complete url as listed hereunder;-

<select name="lm_country" id="lm_coutry" 
    onChange="getCity('http://localhost/civic/includes/getcities.php?country='+this.value)">
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top