admin管理员组文章数量:1334204
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:
本文标签: ajaxwpverifynonce not working on the mobile device
版权声明:本文标题:ajax - wp_verify_nonce not working on the mobile device 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742250008a2440574.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论