WordpressのAJAXを介して投稿からコンテンツを取得しようとしています
これがjsの部分です
$("a.ajaxed").click(function(event) {
event.preventDefault();
doAjaxRequest();
});
function doAjaxRequest(){
jQuery.ajax({
type: 'POST',
url: ajax_object.ajaxurl,
data: ({action : 'ajaxify',
post_id: $(this).attr('id')
}),
dataType: 'JSON',
success:function(data){
console.log(data.post_title);
}
});
}
これはfunctions.phpの部分です
function ajaxify() {
$post_id = $_POST['post_id'];
$post_data = get_post($post_id);
echo json_encode($post_data);
}
console.log(data.post_title)は常にundefinedを表示します。