无论我尝试了什么,wp请求都会提供0作为响应。我在谷歌(including this in SOF)上看到了许多解决方案、文章和答案,我相信我的代码是正确的。
我的ajax调用如下:
$.ajax( {
url : base_url
+ "/wp-admin/admin-ajax.php",
type : 'POST',
cache : false,
dataType : "json",
data: {action: "get_next_post_with_ajax"},
success: function(response){
// functions I'll work on success..
}
});ajax处理程序的...and操作如下所示:
add_action("wp_ajax_nopriv_get_next_post_with_ajax", "get_next_post_with_ajax");
function get_next_post_with_ajax($args) {
echo "test";
die();
}现在谢谢你的帮助。
发布于 2015-08-11 19:54:57
尝试为来自经过身份验证的用户的ajax调用添加add_action("wp_ajax_get_next_post_with_ajax", "get_next_post_with_ajax");。
https://stackoverflow.com/questions/31950564
复制相似问题