I think @James is right. Basically : in the show($id), the value of $post is not the object you are expecting from the DB, it is false.
And when you try to read the property userid from false instead of an object, it gives you this error.
There are some things to check :
let post_id = btn.getAttribute("data-post-id"); gets you exactly the post_id you expect and is correctly sentpost_id sent from xhr is the good one when it arrives to show($id)show($id) that $id is a valid value (not "" or 0 or false for example)$this->postModel->getPostById() does correctly its job$id exists in your database if there is still the problem (if it doesn't, you have a problem somewhere else)I think you'll be able to solve your problem with that.