请注意,您的ajax请求只对登录用户有效。如果你想让它对每个人都有效,你必须再增加一个动作wp_ajax_nopriv_myajaxpagination
使用相同的挂钩:
function videospage(cnt)
{
var pageno=cnt;
jQuery.ajax({
type: "POST",
url: "<?php echo admin_url(\'admin-ajax.php\'); ?>",
data: {
action: "myajaxpagination",
pageno: pageno,
},
success: function(datas){
alert(datas);
},
error: function(MLHttpRequest, textStatus, errorThrown){
alert(errorThrown);
}
});
}
add_action(\'wp_ajax_myajaxpagination\', \'my_action_pagination\');
add_action(\'wp_ajax_nopriv_myajaxpagination\', \'my_action_pagination\');
function my_action_pagination()
{
$pageno=$_REQUEST[\'pageno\'];
echo $pageno;
die();
}
了解更多信息
AJAX in WordPress.