function deleteFunction(e) {
e.preventDefault(this);
$.ajax({
url: '/post_delete',
data: {post_id: this.attr.id},
method: 'POST',
success: function(){
}
});
};
<div id="'.$posts->id.'" onclick ="deleteFunction(this)">Удалить пост</div>';