ajax - wp_verify_nonce not working on the mobile device

I am using a very simple form request to and verify it through the wp_verify_nonce() function. It is working perfectly o

I am using a very simple form request to and verify it through the wp_verify_nonce() function. It is working perfectly on the desktop. But not working on mobile devices( iPhone, Andriod ). Could someone help me to identify the issue?

HTML Code

<form action="" method="POST" id="test-form" novalidate="novalidate">
    <?php wp_nonce_field( 'irw_gzip_action', 'irw_gzip_field' ); ?>
</form>

JavaScript

var $self = $(this);
var $nonce = $('#irw_gzip_field', $self).val();

$.ajax({
    url: WT.ajaxurl, 
    type: 'POST', 
    datatype: 'json',
    data: {
        _ajax_nonce: $nonce,
        action: 'check_action'
    }
})

PHP Code

add_action( 'wp_ajax_nopriv_check_domain', array( $this, 'handle_domain_request' ) );
add_action( 'wp_ajax_check_domain', array( $this, 'handle_domain_request' ) );

public function handle_domain_request() {

    if ( ! isset( $_POST['_ajax_nonce'] ) || 
        ! wp_verify_nonce( $_POST['_ajax_nonce'], 'irw_gzip_action' )
    ) {
        return wp_send_json( array(
            'error' => 'Un-Authorized request!'
        ), 401);
    }
} 

Complete Codes:

Javascript:

HTML:

PHP:

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742250008a4408965.html

相关推荐

  • ajax - wp_verify_nonce not working on the mobile device

    I am using a very simple form request to and verify it through the wp_verify_nonce() function. It is working perfectly o

    1天前
    10

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信