Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am working on a small community style website for my family to use. Mainly it is a small version of a social network so my nieces and nephews can have fun with each other.

I have set up "freinding" functionality and it works fine. But when I respond to a friend request an additional ajax function is fired. My AJAX function works and updates the database, but fails to send an email notification whic I think is due to the additional ajax function being fired.

After submitted the response (accept or ignore) FireBug shows my AJAX function has been moved temporarily - I see a 302 Moved Temporarily error. The just underneath it an additional GET request fires for the user I am logged in as. The Headers looks something like this in FireBug:

Cache-Control   no-cache, must-revalidate, max-age=0
Connection  Keep-Alive
Content-Type    text/html; charset=UTF-8
Date    Tue, 27 Nov 2012 20:51:46 GMT
Expires Wed, 11 Jan 1984 05:00:00 GMT
Keep-Alive  timeout=10, max=29
Last-Modified   Tue, 27 Nov 2012 20:51:46 GMT
Pragma  no-cache
Server  Apache
Transfer-Encoding   chunked
Vary    Accept-Encoding
X-Pingback  http://obeliskwebdesign.com/sandbox/family-site/xmlrpc.php

I am not sure what this additional function is or why it fires. I have several other AJAX functions in the site which work fine and have no additional functions firing after them so I am at a bit of a loss here.

If anyone can shed some light on what may be the cause of this, or if it could be causing my email notification to not fire please let me know. Thanks!

---- EDIT ---------------------------------------------------------

My AJAX function:

//ajax for friend response submission
jQuery('.friend-request-response').click(function(event){
    event.preventDefault();
    var id = $(this).attr('rel');
    var form = jQuery( 'form#friend-response-form-'+id ),
        friend_request_response_nonce = form.find( 'input[name="friend_request_response_nonce"]' ).val(),
        request_id = form.find( 'input[name="request_id"]' ).val(),
        userid = form.find( 'input[name="userid"]' ).val(),
        friend_id = form.find( 'input[name="friend_id"]' ).val(),
        status = form.find( 'input[name="status"]' ).val();

    jQuery('div#request-' + id + 'ul').hide('slow');
    jQuery.post(
        UiAjax.ajaxurl,
        {
            action : 'friend_request_response_action',
            friend_request_response_nonce : friend_request_response_nonce,
            //other parameters
            request_id : request_id,
            userid : userid,
            friend_id : friend_id,
            status : status
        },
        function( response, data ) {
            var new_status = ucFirst( status );
            jQuery('div#request-' + id).html('<p>' + new_status + '</p>').show('slow');
        }
    );
    return false;       
});
share|improve this question
    
Without seeing your AJAX handlers it is impossible to answer that. –  toscho Nov 28 '12 at 7:01
    
Just added my AJAX function. Do you need the PHP functions as well? –  dkmojo Nov 29 '12 at 14:33
add comment

1 Answer

up vote 0 down vote accepted

After a little digging I found that the method I used for handling my email notifications was receiving the user ID as a string. As soon as I cast it as an integer all my notifications started sending. So the additional AJAX function that was firing had no affect on my notification email being sent.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.