I know it pasts a long time of this question.
But I had the same issue and it was difficult for me to find some documentation about it. I had the same problem, for some reason wp_create_nonce and wp_verify_nonce they bot retrieve different hash. So I notice the problem was the $User->ID or $uid that these two function uses to hash the nonce.
I just trying to create the nonce inside the script but for some reason the uid become 0, and what I did, is to create the nonce before and outside the script block and print the value inside the script.
First it was like this (WRONG):
var action = 'submit_user_review';
var ajax_nonce="<?php echo wp_create_nonce("security'); ?>';
jQuery.ajax({
url: my_ajax_object.ajax_url,
type: 'POST',
data: {
action: action,
listing_id: rest_id,
review: comment,
rate: rate,
security_review: ajax_nonce,
},
beforeSend: function() {
// Show full page LoadingOverlay
jQuery.LoadingOverlay("show");
},
and after like this (GOOD):
<?php //Set Your Nonce
$ajax_nonce_review = wp_create_nonce( "submit-user-review" );
?>
<script>
var action = 'submit_user_review';
jQuery.ajax({
url: my_ajax_object.ajax_url,
type: 'POST',
data: {
action: action,
listing_id: rest_id,
review: comment,
rate: rate,
security_review: '<?php echo $ajax_nonce_review; ?>',
},
beforeSend: function() {
// Show full page LoadingOverlay
jQuery.LoadingOverlay("show");
},
And that fix my problem, literally spend one day trying to figure it out this.
I hope it helps somebody else.