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.
$.ajax({
    type: "POST",
    dataType: "text",
    url: ajaxurl,
    data: {
            action: "more_news",
            nonce: nonce,
            offset: offset
    },
    success : function(data, textStatus, jqXHR){
        console.log( nonce );
        console.log( data );
        console.log( textStatus );
    }
});

Checking for this AJAX request nonce locally works perfectly. As seen below, my console prints my nonce, "Awesome", and then "success".

9a91a5fdca
Awesome
success

When on my server, my console prints my nonce TWICE (thus proving to me they're exactly the same), then success.

e2ca4eca80
e2ca4eca80
success

I'm… confused… to say the least. How is this possible? and how do I solve it?

add_action( 'wp_ajax_more_news', 'more_news' );
add_action( 'wp_ajax_nopriv_more_news', 'more_news' );

function more_news(){
    if ( !wp_verify_nonce($_POST['nonce'], 'more_news_nonce') ){
        exit($_POST['nonce']);
    }
    echo 'Awesome';
    die();
}
share|improve this question
1  
Can you show the code used to create your nonce? –  vancoder Apr 3 '13 at 21:45
    
this inexplicably has started working on the server. caching issue? apache bug? I'm not sure what happened, but it's working now –  zack Apr 3 '13 at 22:29
add comment

1 Answer 1

The second parameter for wp_verify_nonce() is the action. That part is not in your question, but I guess it should be called like:

if ( !wp_verify_nonce($_POST['nonce'], $_POST['action']) ){
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.