$.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();
}
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:Isn’t action be the same as you sent?
I assume it should be
it should be,
and wp function